fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5. #define yes cout << "YES\n"
  6. #define no cout << "NO\n"
  7. #define el "\n"
  8. #define Arwa ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  9. #define fix(x) cout << fixed << setprecision(x)
  10. #define all(v) v.begin(), v.end()
  11.  
  12. void file()
  13. {
  14. //#ifndef ONLINE_JUDGE
  15. freopen("input.txt", "r", stdin);
  16. freopen("output.txt", "w", stdout);
  17. //#endif
  18. }
  19.  
  20. int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
  21. int lcm(int a, int b) { return a / gcd(a, b) * b; }
  22. bool prime(int n) {
  23. if (n == 2) return true;
  24. if (n % 2 == 0 || n == 1) return false;
  25. for (int i = 3; i * i <= n; i += 2)
  26. if (n % i == 0) return false;
  27. }
  28. bool isPowerOf2(int n)
  29. {
  30. return !(n&(n-1));
  31. }
  32. int32_t main()
  33. {
  34. Arwa
  35. int t=1;
  36. //cin>>t;
  37. while(t--)
  38. {
  39. int n,q;
  40. cin>>n>>q;
  41. while(q--)
  42. {
  43. int op;
  44. cin>>op;
  45. if(op==1)
  46. n|=(n+1);
  47. else if(op==2)
  48. n&=(n-1);
  49. else if(op==3)
  50. {
  51. if(n!=0)
  52. n|=(n-1);
  53. else n=-1;
  54. }
  55. else if(op==4)
  56. n&=(n+1);
  57. else if(op==5)
  58. {
  59. if(isPowerOf2(n)&&n!=0)
  60. cout<<"is power of two"<<el;
  61. else
  62. cout<<"not power of two"<<el;
  63. }
  64. if(op!=5)
  65. cout<<n<<el;
  66. }
  67.  
  68. }
  69. return 0;
  70. }
  71.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty