Advertisement
Asif_Anwar

Problem-3(Sharing after contest)

Jun 24th, 2021
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.76 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. //using namespace chrono;
  5.  
  6. typedef long long ll;
  7. typedef vector< int > vi;
  8. typedef vector< ll > V;
  9. typedef map<int, int > mp;
  10.  
  11. #define pb push_back
  12. #define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  13. #define F first
  14. #define S second
  15.  
  16. #define debug cout << -1 << endl;
  17. #define REP(i, a, b) for(int i=a; i<b; i++)
  18. #define f0r(i, n) for (int i = 0; i < n; ++i)
  19. #define f0r1(i, n) for (int i = 1; i <= n; ++i)
  20. #define r0f(i, n) for(int i=n-1; i>=0; i--)
  21. #define r0f1(i, n) for(int i=n; i>=1; i--)
  22. #define fore(a, x) for (auto& a : x)
  23. #define fori(i, a, b) for (int i = (a); i < (b); ++i)
  24.  
  25. #define MP make_pair
  26. #define UB upper_bound
  27. #define LB lower_bound
  28. #define nw cout << "\n"
  29.  
  30. #define issq(x) (((ll)(sqrt((x))))*((ll)(sqrt((x))))==(x))
  31. #define rev(v) reverse(v.begin(),v.end())
  32. #define asche cerr<<"Ekhane asche\n";
  33. #define rev(v) reverse(v.begin(),v.end())
  34. #define srt(v) sort(v.begin(),v.end())
  35. #define grtsrt(v) sort(v.begin(),v.end(),greater<ll>())
  36. #define all(v) v.begin(),v.end()
  37. #define mnv(v) *min_element(v.begin(),v.end())
  38. #define mxv(v) *max_element(v.begin(),v.end())
  39. #define valid(tx,ty) (tx>=0 && tx<n && ty>=0 && ty<m)
  40. #define one(x) __builtin_popcount(x)
  41. //#define pop pop_back
  42. #define setPrec(x) cout << fixed << setprecision(x)
  43. #define sz(a) (int)a.size()
  44. //#define fin cin
  45. //#define fout cout
  46. const int INF = 1e9;
  47. const ll MOD = (ll)1e9+7;
  48. const ll INFL = 1e18;
  49. const ll mnINF = -1e18;
  50. const double diff = 10e-6;
  51. const int maxn = 500005;
  52. const double PI = acos(-1);
  53. using namespace std;
  54.  
  55. // int dx[] = {-1, 0, 1};
  56. // int dy[] = {-1, 0, 1};
  57.  
  58. int dx[] = {-1, 0, 0, 1};
  59. int dy[] = {0, -1, 1, 0};
  60.  
  61. vector< ll > v;
  62. int arr[] = {4, 7};
  63.  
  64. void gen2()
  65. {
  66.     ll x = 0LL;
  67.     f0r(i, 2) f0r(j, 2) {
  68.         x = arr[i]*10 + arr[j];
  69.         v.pb(x);
  70.     }
  71. }
  72.  
  73. void gen3()
  74. {
  75.     ll x = 0LL;
  76.     f0r(i, 2) f0r(j, 2) f0r(k, 2) {
  77.         x = arr[i]*100 + arr[j]*10 + arr[k];
  78.         v.pb(x);
  79.     }
  80. }
  81.  
  82. void gen4()
  83. {
  84.     ll x = 0LL;
  85.     f0r(i, 2) f0r(j, 2) f0r(k, 2) f0r(l, 2) {
  86.         x = arr[i]*100 + arr[j]*10 + arr[k];
  87.         x*=10LL;
  88.         x += arr[l];
  89.         v.pb(x);
  90.     }
  91. }
  92.  
  93. void gen5()
  94. {
  95.     ll x = 0LL;
  96.     f0r(i, 2) f0r(j, 2) f0r(k, 2) f0r(l, 2) f0r(m, 2){
  97.         x = arr[i]*100 + arr[j]*10 + arr[k];
  98.         x*=10LL;
  99.         x += arr[l];
  100.         x *= 10LL;
  101.         x += arr[m];
  102.         v.pb(x);
  103.     }
  104. }
  105.  
  106. void gen6()
  107. {
  108.     ll x = 0LL;
  109.     f0r(i, 2) f0r(j, 2) f0r(k, 2) f0r(l, 2) f0r(m, 2) f0r(o, 2){
  110.         x = arr[i]*100 + arr[j]*10 + arr[k];
  111.         x*=10LL;
  112.         x += arr[l];
  113.         x *= 10LL;
  114.         x += arr[m];
  115.         x *= 10LL;
  116.         x += arr[o];
  117.         v.pb(x);
  118.     }
  119. }
  120.  
  121. void gen7()
  122. {
  123.     ll x = 0LL;
  124.     f0r(i, 2) f0r(j, 2) f0r(k, 2) f0r(l, 2) f0r(m, 2) f0r(o, 2) f0r(p, 2){
  125.         x = arr[i]*100 + arr[j]*10 + arr[k];
  126.         x*=10LL;
  127.         x += arr[l];
  128.         x *= 10LL;
  129.         x += arr[m];
  130.         x *= 10LL;
  131.         x += arr[o];
  132.         x *= 10LL;
  133.         x += arr[p];
  134.         v.pb(x);
  135.     }
  136. }
  137.  
  138. void gen8()
  139. {
  140.     ll x = 0LL;
  141.     f0r(i, 2) f0r(j, 2) f0r(k, 2) f0r(l, 2) f0r(m, 2) f0r(o, 2) f0r(p, 2) f0r(q, 2){
  142.         x = arr[i]*100 + arr[j]*10 + arr[k];
  143.         x*=10LL;
  144.         x += arr[l];
  145.         x *= 10LL;
  146.         x += arr[m];
  147.         x *= 10LL;
  148.         x += arr[o];
  149.         x *= 10LL;
  150.         x += arr[p];
  151.         x *= 10LL;
  152.         x += arr[q];
  153.         v.pb(x);
  154.     }
  155. }
  156.  
  157. void gen9()
  158. {
  159.     ll x = 0LL;
  160.     f0r(i, 2) f0r(j, 2) f0r(k, 2) f0r(l, 2) f0r(m, 2) f0r(o, 2) f0r(p, 2) f0r(q, 2) f0r(r, 2){
  161.         x = arr[i]*100 + arr[j]*10 + arr[k];
  162.         x*=10LL;
  163.         x += arr[l];
  164.         x *= 10LL;
  165.         x += arr[m];
  166.         x *= 10LL;
  167.         x += arr[o];
  168.         x *= 10LL;
  169.         x += arr[p];
  170.         x *= 10LL;
  171.         x += arr[q];
  172.         x *= 10LL;
  173.         x += arr[r];
  174.         v.pb(x);
  175.     }
  176. }
  177.  
  178. void solve()
  179. {
  180.     v.pb(4);
  181.     v.pb(7);
  182.     gen2(); gen3(); gen4(); gen5(); gen6(); gen7(); gen8();
  183.     gen9();
  184.     // for(auto xx: v) cout << xx << "\n";
  185.     ll x;
  186.     cin >> x;
  187.     cout << upper_bound(v.begin(), v.end(), x)-v.begin() << "\n";
  188. }
  189.  
  190.  
  191.  
  192. void setIO(string name = "") { // name is nonempty for USACO file I/O
  193.  
  194.     ios_base::sync_with_stdio(0); cin.tie(0); // see Fast Input & Output
  195.  
  196.     // alternatively, cin.tie(0)->sync_with_stdio(0);
  197.  
  198.     if (name.size()) {
  199.  
  200.         freopen((name+".in").c_str(), "r", stdin); // see Input & Output
  201.  
  202.         freopen((name+".out").c_str(), "w", stdout);
  203.  
  204.     }
  205.  
  206. }
  207.  
  208. int main()
  209. {
  210.     //setIO("breedflip");
  211.     FastIO;
  212.     int t;
  213.     t = 1;
  214.     // cin >> t;
  215.     f0r(i, t) {
  216.         //cout << "Case " << i+1 << ": ";
  217.         solve();
  218.     }
  219.     return 0;
  220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement