Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.     ios::sync_with_stdio(0),cin.tie(0);
  7.     int T,i,n;
  8.     int sum,cmd;
  9.     string str;
  10.     for(cin>>T;T;T--){
  11.         cin>>str;
  12.         n=str.size();
  13.         cmd=sum=0;
  14.         for(i=n-1;i>=0;i--){
  15.             if(str[i]=='1'){
  16.                 if(cmd==0){
  17.                     sum+=1;
  18.                 }else if(cmd==1){
  19.                     sum+=2;
  20.                 }
  21.             }
  22.             cmd=cmd^1;
  23.         }
  24.         if(sum%3){
  25.             cout<<"No\n";
  26.         }else{
  27.             cout<<"Yes\n";
  28.         }
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement