题解:AT_joi2027_yo1b_d ペア (Pairs)

· · 题解

传送门

题目大意

问字符串 s 重复 k 遍之后是否包含另一个字符串 t。

分析

发现两个字符串都很短,但是 k 非常大,很显然 k 是用不着这么大的,所以只要把 k 缩到一个不大的数然后模拟就可以了。

Code

#include<iostream>
#include<string>
using namespace std;
int main(){
    int n,m,k;
    string s,t,x;
    cin>>n>>s>>m>>t>>k;
    if(k>105)
        k=105;
    while(k--)
        x+=s;
    if(x.find(t)!=string::npos)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

提交记录