2020-07-12 遍历问题

2020-07-12  本文已影响0人  JalorOo

题目:https://www.luogu.com.cn/problem/P1229

#include<cstdio>
#include<cstring>
#include<cmath>
#include <iostream>
#include<algorithm>
using namespace std;

int read(){
    int x=0,f=1;
    char c = getchar();
    while(c<'0'||c>'9'){//符号位
        if(c=='-')
            f=-1;
        c = getchar();
    }
    while(c>='0'&&c<='9'){//数字
        x = x*10 + c -'0';
        c=getchar();
    }
    return x*f;
}

int ans;
string str1,str2;
int main()
{
    cin>>str1>>str2;
    for(int i=0;i<str1.length();i++){
        for(int j=1;j<str2.length();j++){
            if(str1[i]==str2[j] && str1[i+1]==str2[j-1] ){
                ans++;
            }
        }
    }
    printf("%d",1<<ans);//1<<ans 相当于 ans*2
    return 0;
}
/*
abc
cba
*/

上一篇 下一篇

猜你喜欢

热点阅读