提交时间:2022-10-15 11:24:48

运行 ID: 60311

#include<bits/stdc++.h> using namespace std; int t; string a,b; int main() { cin>>t; for(;t>0;t--){ cin>>a>>b; int ch=0,n=a.length(),m=b.length(); // cout<<n<<' '<<m<<endl; if(n%m!=0) cout<<"NO"<<endl; else if(n<m) cout<<"NO"<<endl; else{ for(int i=0;i<n;i++){ // cout<<a[i]<<' '<<b[i%m]<<endl<<i%m<<endl; if(a[i]!=b[i%m]){ cout<<"NO"<<endl;ch=1; break; } } if(!ch) cout<<"YES"<<endl; } } return 0; }