Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;  
  4.  
  5. #define ll long long
  6. #define pb push_back
  7.  
  8. ll n;
  9. vector <ll> a;
  10.  
  11. void rec(int q, int w, ll e)
  12. {
  13.     if (q == w && e >= n)
  14.     {
  15.         a.pb(e);
  16.     }
  17.     if (q + w > 10)
  18.     {
  19.         return;
  20.     }
  21.     rec(q+1,w,(ll)(e*10+4));
  22.     rec(q,w+1,(ll)(e*10+7));
  23. }
  24.    
  25. int main ()
  26. {
  27.     ios_base::sync_with_stdio(false);
  28.     cin.tie(0);
  29.     cin >> n;
  30.     rec(0,0,0);
  31.     sort(a.begin(),a.end());
  32.     cout << a[0];
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement