提交时间:2022-07-19 12:01:57

运行 ID: 52368

/* ljhelloh hellohlj 2 4 ohljhell */ #include <bits/stdc++.h> using namespace std; string s; string r; int a,b; int n; int getLoop(string a,string b){ string s=a+a; string r=b; if(a.length()!=b.length()){ return -1; } else{ for(int i=0;i<a.length();i++){ if(r.compare(s.substr(i,a.length()))==0){ return i; } } return -2; } } bool broke(int x,int A,int B){ int a=max(A,B); int b=min(A,B); for(int i=0;i<=x/a;i++){ if((x-a*i)%b==0){ return true; } } return false; } int main(){ cin>>n; for(int i=0;i<n;i++){ cin>>s; cin>>r; cin>>a>>b; int times=getLoop(s,r); if(times<0){ cout<<"no"<<endl; } else{ if(broke){ cout<<"yes"<<endl; } else{ cout<<"no"<<endl; } } } }