Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- typedef long long LL;
- LL res = LL(1e16), n;
- void rec(LL now, int f, int s)
- {
- if (now > res)
- return;
- if (now >= n)
- {
- if (f == s)
- {
- res = min(now, res);
- return;
- }
- }
- rec(now * 10 + 4, f + 1, s);
- rec(now * 10 + 7, f , s + 1);
- }
- int main()
- {
- cin >> n;
- rec(0, 0, 0);
- cout << res;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement