Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <map>
- using namespace std;
- #define ll long long int
- int n;
- map<int, ll> mp;
- ll solve(int n)
- {
- if(n==0)
- return 0;
- if(mp.count(n))
- return mp[n];
- return mp[n]=max((ll)n, (ll)solve(n/2)+(ll)solve(n/3)+(ll)solve(n/4));
- }
- int main()
- {
- mp.clear();
- while(scanf("%d", &n)!=EOF)
- printf("%lld\n", solve(n));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement