0
点赞
收藏
分享

微信扫一扫

CF 265A(彩石简化版)


A. Colorful Stones (Simplified Edition)



time limit per test



memory limit per test



input



output



 s 表示,第i个为"R", "G", or "B"表示颜色。

"R", "G", or "B"表示,当Liss所在的彩石与操作符相同时,Liss向前走一格,否则不动。(Liss一开始在彩石1处) 

t

请输出Liss最后所占的彩色编号(假设Liss不会走出彩石)



Input



s (1 ≤ |s| ≤ 50). 第二行 t (1 ≤ |t| ≤ 50).



Output



输出一行Liss最后所占的彩色编号.



Sample test(s)



input



RGB RRR



output



2



input



RRRBGBRBBB BBBRR



output



3



input



BRRBGBRGRBGRGRRGGBGBGBRGBRGRGGGRBRRRBRBBBGRRRGGBBB BBRBGGRGRGBBBRBGRBRBBBBRBRRRBGBBGBBRRBBGGRBRRBRGRB



output



15


模拟题,各种做

注意 scanf("%s%s",&s,&t); s和t都是从0开始的

字符串长度函数为strlen(s)



#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<functional>
#include<algorithm>
#include<cctype>
using namespace std;
#define MAXN (50+10)
char s[MAXN],t[MAXN];
int main()
{
scanf("%s%s",&s,&t);
int j=0;
for (int i=0;i<strlen(t);i++)
{
if (t[i]==s[j]) j++;
}
cout<<1+j<<endl;


}



举报

相关推荐

0 条评论