fork(1) download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. #define FAST ios::sync_with_stdio(false);cin.tie(NULL);
  5. #define ll long long
  6. #define ld long double
  7. using namespace std;
  8.  
  9. int n;
  10.  
  11. void func()
  12. {
  13. cin >> n;
  14. if (n == 0)
  15. {
  16. cout << "NO\n";
  17. }
  18. }
  19.  
  20. void func1()
  21. {
  22. if (n > 0)
  23. {
  24. string bin = "";
  25. if (n % 2 != 0)
  26. {
  27. while (n > 0)
  28. {
  29. bin += (n % 2) + '0';
  30. n /= 2;
  31. }
  32. reverse(bin.begin(), bin.end());
  33. bool ok = false;
  34. for (int j = 0; j + 2 < bin.size(); j++)
  35. {
  36. string sub = bin.substr(j, 3);
  37. if (sub == "101" || sub == "11")
  38. {
  39. ok = true;
  40. break;
  41. }
  42.  
  43. }
  44. if (ok)
  45. cout << "NO\n";
  46. else
  47. cout << "YES\n";
  48. }
  49. else
  50. cout << "NO\n";
  51. }
  52. }
  53.  
  54. int main()
  55. {
  56. FAST;
  57. func();
  58. func1();
  59.  
  60. return 0;
  61. }
  62.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
NO