当前位置:网站首页>Stocking but not completely stocking (daily question 2 in spring)
Stocking but not completely stocking (daily question 2 in spring)
2022-06-25 01:50:00 【51CTO】
A little-known fact is , Cows have their own words :「 Niu Wen 」.
Niu Wenyou Letters
a To z form , But when the cow says Niu Wen , May be familiar to us abcdefghijklmnopqrstuvwxyz Different , She will arrange the letters in a certain order .
To pass the time , cow Bessie Humming the cow alphabet song repeatedly , and Farmer John Wonder how many times she sang .
Given a string of lowercase letters , by Farmer John hear Bessie Sing the letters , Calculation Bessie At least a few times I sang the complete song of the cow alphabet , bring Farmer John Can hear a given string .
Farmer John Not always pay attention to Bessie What you sing , So he may miss listening Bessie Some of the letters sung .
The given string contains only the letters he remembers he hears .
Input format
The first line of input contains Lowercase letters , by
a To z The order of the Niu alphabet .
The next line contains a string of lowercase letters , by Farmer John hear Bessie Sing the letters .
Output format
Output Bessie The minimum number of complete niuwen alphabet songs sung .
Data range
The length of the string is not less than And not more than
.
sample input :
sample output :
Sample explanation
In this example , The Niu alphabet is in line with the daily alphabet .
Bessie At least three times .
There may be Bessie I only sang the song of the cow alphabet three times , and Farmer John I heard the following capitalized letters .
using
namespace
std;
const
int
N
=
1010;
char
a[
30],
s[
N];
int
pos[
30];
int
main(){
scanf(
"%s",
a);
for(
int
i
=
0;
i
<
26;
i
++)
pos[
a[
i]
-
'a']
=
i;
scanf(
"%s",
s);
int
n
=
strlen(
s);
int
pre
=
30;
int
res
=
0;
for(
int
i
=
0;
i
<
n;
i
++){
int
x
=
pos[
s[
i]
-
'a'];
if(
x
<=
pre)
res
++;
pre
=
x;
}
cout
<<
res
<<
endl;
return
0;
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
边栏推荐
- 音频PCM数据计算声音分贝值,实现简单VAD功能
- Pbcms adding cyclic digital labels
- Reading notes at night -- deep into virtual function
- Unity C # e-learning (VI) -- FTP (I)
- lnmp环境安装ffmpeg,并在Yii2中使用
- js数组对象转对象
- The innovation consortium of Haihe laboratory established gbase and became one of the first member units of the innovation Consortium (Xinchuang)
- WinXP内核驱动调试
- IPC mechanism
- Numerical scheme simulation of forward stochastic differential equations with Markov Switching
猜你喜欢

Abnova丨A4GNT多克隆抗体中英文说明

Q1季度逆势增长的华为笔电,正引领PC进入“智慧办公”时代

1. package your own scaffold 2 Create code module

After integrating the aurora push plug-in in the uni app, the real machine debugging prompts "the currently running base does not contain the native plug-in [jg-jpush]..." Solutions to problems

Bi-sql index
![搜索二维矩阵[二分巧用 + 记录不同于插入二分的解法]](/img/c9/afc03afd477bbfdd3c0dc54bacfd2d.png)
搜索二维矩阵[二分巧用 + 记录不同于插入二分的解法]

(CVPR 2020) Learning Object Bounding Boxes for 3D Instance Segmentation on Point Clouds

JS array object to object

Baidu voice synthesizes voice files and displays them on the website

Ps5 connected to oppo K9 TV does not support 2160p/4k
随机推荐
sql 聚合函数对 null 的处理[通俗易懂]
Redis basic commands and types
C语言边界计算和不对称边界
Abnova丨CSV 磁珠中英文说明
Deoxyribonuclease I instructions in Chinese and English
字符串常用方法
Audio PCM data calculates sound decibel value to realize simple VAD function
Numerical scheme simulation of forward stochastic differential equations with Markov Switching
How to prepare for the last day of tomorrow's exam? Complete compilation of the introduction to the second building test site
lnmp环境安装ffmpeg,并在Yii2中使用
Hands on data analysis data modeling and model evaluation
IPC mechanism
TC对象结构和简称
Transformers 库的基本使用
AutoCAD - two extension modes
創新藥二級市場審餅疲勞:三期臨床成功、產品獲批也不管用了
Redis persistence
Bi-sql index
Excel Chinese character to pinyin "suggestions collection"
An Chaoyun: "one cloud with multiple cores" supports the implementation of the national information innovation government cloud