美文网首页
2020-07-12 遍历问题

2020-07-12 遍历问题

作者: JalorOo | 来源:发表于2020-07-12 23:12 被阅读0次

题目: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
*/

相关文章

  • 2020-07-12 遍历问题

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

  • 遍历问题

    对于多个同名的class来讲,要一次性获取它们,最好用遍历,而不是直接$('.class'),有时候,程序会只获取...

  • 背包问题合集

    背包问题 判断是排列问题 还是 组合问题 确定遍历顺序: 如果求组合数就是外层for循环遍历物品,内层for遍历背...

  • Cannot copy to a TensorFlowLite

    2020-07-12 18:03:05.160 14845-14883/? E/AndroidRuntime: F...

  • GEO数据库-ID转换系列

    作者:jzhang Update:2020-07-12 Emali:jzhang910@qq.com 前言:我们都...

  • JavaScript遍历问题

    问题描述 我们有一个对象数组,里面存储着通讯录。 函数 lookUp 有两个预定义参数:firstName值和pr...

  • Linklist遍历问题

    昨天晚上跟同事吃饭的时候 说道之前面试的时候 面试官问他的一个问题 在遍历linklist的时候 使用for(i=...

  • LeetCode之Letter Tile Possibiliti

    问题: 方法:深度优先遍历加染色提高遍历效率。 有问题随时沟通 具体代码实现可以参考Github[https://...

  • 图的遍历——深度优先遍历问题

    从这道题来看,深度优先搜索遍历这个图:首先从没有走到过的顶点作为起始点,假如从1开始作为起始点,与1相连接的有顶点...

  • Objective-C 数组遍历的性能及原理

    数组的遍历,这个话题貌似没什么好探究的,该怎么遍历就怎么遍历呗!但是如果要回答这些问题:OC数组有哪几种遍历方式?...

网友评论

      本文标题:2020-07-12 遍历问题

      本文链接:https://www.haomeiwen.com/subject/nacocktx.html