提交时间:2022-07-19 11:51:48

运行 ID: 52290

#include<bits/stdc++.h> #define int long long using namespace std; inline int read(){ int x=0,f=0;char c=getchar(); while(c<48||c>57)f|=(!(c^'-')),c=getchar(); while(c>=48&&c<=57)x=(x<<1)+(x<<3)+(c^48),c=getchar(); return f?-x:x; } int t,a,b; string s1,s2; signed main(){ t=read(); while(t--){ cin>>s1>>s2; a=read(),b=read(); if(s1==s2)puts("yes"); else{ string ss; bool flag=1; int x=abs(b-a),d=__gcd(x,(int)s1.size()); for(int i=d;i<s1.size();i+=d){ for(int j=0;j<d;j++)s1+=s1[j]; s1.erase(s1.begin(),s1.begin()+d); if(s1==s2){puts("yes");flag=0;break;} } if(flag)puts("no"); } } return 0; }