提交时间:2022-07-19 12:11:51
运行 ID: 52438
#include <bits/stdc++.h> using namespace std; int n,a,b; bool f; int l; string s1,s2; string s4,s3; bool check() { int k; for (int i=0; i<=l*__gcd(l+1,abs(a-b))*2+1+2; i++) { f=1; for (int j=i; j<=i+l-1+1; j++) { k=i;//+1 if (s1[j]!=s2[j-i]) { f=0; break;//p } } if (f==1 && ((l+1-k)%abs(a-b)==0|| k%abs(a-b)==0))//a return 1; //\\lag = } return 0;//return 1; } int main() { cin>>n; //int l; for (int i=1; i<=n; i++) { cin >> s1>>s2>>a>>b; s3=""; s4="";// // l=s1.size()-1;// for (int i=0; i<=a-1; i++) { s3+=s1[a-1-i]; } for (int i=a-1+1; i<=l-1+1; i++) { s3+=s1[l-i+a-1]; } for (int i=0; i<=b-1; i++) { s4+=s1[a-1-i]; } for (int i=b-1+1; i<=l-1+1; i++) { s4+=s1[l-i+a-1]; } s1+=s1; s1+=s1; // for (int i=2; i<=(__gcd(l+1,abs(a-b))); i++) { s1+=s1; s1+=s1; } if (check() || s3==s1 || s4==s1) cout<<"yes"<<endl; else cout<<"no"<<endl; //cout<<s3<<endl<<endl; s3=""; s4="";// // } return 0; }