分析:直接看n/k的奇偶性
1 #include "iostream" 2 #include "cstdio" 3 #include "cstring" 4 using namespace std; 5 long long n,k; 6 int main() 7 { 8 cin>>n>>k; 9 long long res=n/k; 10 if(res==0){ 11 cout<<"NO"<<endl; 12 }else{ 13 if(res%2){ 14 cout<<"YES"<<endl; 15 }else{ 16 cout<<"NO"<<endl; 17 } 18 } 19 }
分析:?可以替换成好字母,*可以替换成除了好字母意外以外的一切字符串,这个要注意,然后直接模拟就好了
1 #include "iostream" 2 #include "cstdio" 3 #include "cstring" 4 #include "string" 5 using namespace std; 6 const int maxn=1e5+10; 7 char a[maxn],b[maxn]; 8 int vis[500]; 9 int q; 10 int main() 11 { 12 char ch=getchar(); 13 int t=0; 14 while(ch!=' ') a[++t]=ch,ch=getchar(); 15 for(int i=1;i<=t;i++) 16 vis[a[i]]=1; 17 ch=getchar(); 18 int n=0; 19 while(ch!=' ') b[++n]=ch,ch=getchar(); 20 int z=0; 21 for(int i=1;i<=n;i++) 22 if(b[i]=='*'){ 23 z=1; break; 24 } 25 scanf("%d",&q); 26 getchar(); 27 for(int cas=1;cas<=q;cas++){ 28 char res[maxn]; 29 ch=getchar(); 30 int m=0; 31 int flag=0; 32 while(ch!=' ') res[++m]=ch,ch=getchar(); 33 if(m<n-1||(!z&&m!=n)){ 34 cout<<"NO"<<endl; 35 continue; 36 } 37 for(int i=1;i<=n;i++){ 38 if(b[i]=='*'){ 39 for(int j=i;j<=i+m-n;j++) if(vis[res[j]]){ 40 flag=1; break; 41 } 42 if(flag) break; 43 if(m==n-1) for(int j=n;j>i;j--) res[j]=res[j-1]; 44 else for(int j=i;j<=n;j++) res[j]=res[j+m-n]; 45 }else if(b[i]=='?'){ 46 if(!vis[res[i]]){ 47 flag=1; break; 48 } 49 }else{ 50 if(b[i]!=res[i]){ 51 flag=1;break; 52 } 53 } 54 } 55 if(!flag) cout<<"YES"<<endl; 56 else cout<<"NO"<<endl; 57 } 58 return 0; 59 }