当前位置:网站首页>放养但没有完全放养(春季每日一题 2)
放养但没有完全放养(春季每日一题 2)
2022-06-24 21:39:00 【51CTO】
一个鲜为人知的事实是,奶牛拥有自己的文字:「牛文」。
牛文由 个字母
a 到 z 组成,但是当奶牛说牛文时,可能与我们所熟悉的 abcdefghijklmnopqrstuvwxyz 不同,她会按某种特定的顺序排列字母。
为了打发时间,奶牛 Bessie 在反复哼唱牛文字母歌,而 Farmer John 好奇她唱了多少遍。
给定一个小写字母组成的字符串,为 Farmer John 听到 Bessie 唱的字母,计算 Bessie 至少唱了几遍完整的牛文字母歌,使得 Farmer John 能够听到给定的字符串。
Farmer John 并不始终注意 Bessie 所唱的内容,所以他可能会漏听 Bessie 唱过的一些字母。
给定的字符串仅包含他记得他所听到的字母。
输入格式
输入的第一行包含 个小写字母,为
a到z的牛文字母表顺序。
下一行包含一个小写字母组成的字符串,为 Farmer John 听到 Bessie 唱的字母。
输出格式
输出 Bessie 所唱的完整的牛文字母歌的最小次数。
数据范围
字符串的长度不小于 且不大于
。
输入样例:
输出样例:
样例解释
在这个样例中,牛文字母表与日常的字母表的排列一致。
Bessie 至少唱了三遍牛文字母歌。
有可能 Bessie 只唱了三遍牛文字母歌,而 Farmer John 听到了以下被标记为大写的字母。
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.
边栏推荐
- 修身励学篇
- Bi SQL constraints
- Poj3669 meteor shower (BFS pretreatment)
- String common methods
- Abnova丨5-甲基胞嘧啶多克隆抗体中英文说明
- 安超云:“一云多芯”支持国家信创政务云落地
- Multi modal data can also be Mae? Berkeley & Google proposed m3ae to conduct Mae on image and text data! The optimal masking rate can reach 75%, significantly higher than 15% of Bert
- Bi SQL alias
- 门店无线音箱造假?索尼回应:产品预留了有线连接接口 复杂场景下可以使用
- Elastase instructions in Chinese and English
猜你喜欢

ICML2022 | 用神经控制微分方程建立反事实结果的连续时间模型

Pbcms adding cyclic digital labels
![Longest continuous sequence [diffusion method + space for time]](/img/db/7b0d1b0db7015e887340723505153a.png)
Longest continuous sequence [diffusion method + space for time]

pbcms添加循环数字标签

谷歌浏览器控制台 f12怎么设置成中文/英文 切换方法,一定要看到最后!!!

百度语音合成语音文件并在网站中展示

天书夜读笔记——内存分页机制

Tianshu night reading notes -- memory paging mechanism

leetcode:2104. Subarray range and

Bi-sql - different join
随机推荐
归并排序求逆序数
屡获大奖的界面控件开发包DevExpress v22.1官宣发布
天书夜读笔记——反汇编引擎xde32
Unity C# 网络学习(六)——FTP(一)
C语言边界计算和不对称边界
Bi-sql Union
木瓜蛋白酶中英文说明书
Chinese and English instructions of Papain
An Chaoyun: "one cloud with multiple cores" supports the implementation of the national information innovation government cloud
SQL aggregate function handling null [easy to understand]
广发期货安全吗?开户需要什么东西?
Experiment 5 8254 timing / counter application experiment [microcomputer principle] [experiment]
脱氧核糖核酸酶I中英文说明书
RedisTemplate操作Redis,这一篇文章就够了(一)[通俗易懂]
“一个优秀程序员可抵五个普通程序员!”
js数组对象转对象
Chinese and English instructions of trypsin
国内炒股开户正规安全的具体名单
Merge sort template & understanding
TC对象结构和简称