提交时间:2022-07-19 11:52:07

运行 ID: 52310

#include <bits/stdc++.h> using namespace std; string s1,s2; int main(){ int t,a,b; cin>>t; while (t--){ cin>>s1>>s2>>a>>b; if (s1 == s2){ cout<<"yes"<<endl; } else { bool flag = 1; int d = __gcd(abs(a-b),(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){ cout<<"yes"<<endl; flag = 0; break; } } if (flag) cout<<"no"<<endl; } } return 0; }