fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // find if a number is a multiple of 3
  6. int n = 219;
  7. bool flag = true;
  8. int count1 = 0, count2 = 0;
  9. while(n) {
  10. if (flag && (n&1) == 1) count1++;
  11. else if (!flag && (n&1) == 1) count2++;
  12. flag = !flag;
  13. n= n>>1;
  14. }
  15.  
  16. int dif = (count1-count2);
  17.  
  18. if(dif%3==0) cout<<"yes";
  19. else cout<<"no";
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
yes