View difference between Paste ID: 5Uf3ABMB and W4SAEx2t
SHOW: | | - or go back to the newest paste.
1
#include <cstdio>
2-
#include <algorithm>
2+
#include <map>
3
 
4
 using namespace std;
5
 
6
#define ll long long int
7-
7+
8
map<int, ll> mp;
9
 
10-
10+
11
{
12
    if(n==0)
13
        return 0;
14
    if(mp.count(n))
15
        return mp[n];
16
    return mp[n]=max((ll)n, (ll)solve(n/2)+(ll)solve(n/3)+(ll)solve(n/4));
17
}
18
int main()
19
{
20
    mp.clear();
21
    while(scanf("%d", &n)!=EOF)
22
        printf("%lld\n", solve(n));
23
    return 0;
24
}