HDU1854 Q-Sequence
http://acm.hdu.edu.cn/showproblem.php?pid=1854
随手练习
1 #include <bits/stdc++.h> 2 using namespace std; 3 int t; 4 string s; 5 int main(){ 6 scanf("%d",&t); 7 while(t--){ 8 int flag=0; 9 int zero=0; 10 int one=0; 11 string s2; 12 cin>>s2; 13 int len=s2.length(); 14 for(int i=0;i<len;i++){ 15 if(s2[i]=='0'){ 16 zero++; 17 }else{ 18 if(zero==1){ 19 flag=1; 20 } 21 zero--; 22 } 23 } 24 if(flag) cout<<"No"<<endl; 25 else{ 26 cout<<"Yes"<<endl; 27 } 28 } 29 return 0; 30 }