Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define pb push_back
- ll n;
- vector <ll> a;
- void rec(int q, int w, ll e)
- {
- if (q == w && e >= n)
- {
- a.pb(e);
- }
- if (q + w > 10)
- {
- return;
- }
- rec(q+1,w,(ll)(e*10+4));
- rec(q,w+1,(ll)(e*10+7));
- }
- int main ()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cin >> n;
- rec(0,0,0);
- sort(a.begin(),a.end());
- cout << a[0];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement