forked from SharmaManish/Spoj
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbgc.cpp
More file actions
51 lines (34 loc) · 708 Bytes
/
bgc.cpp
File metadata and controls
51 lines (34 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<iostream>
#include<stdio.h>
#include<map>
using namespace std;
map<long long,long long> v;
long long max(long long n,long long k)
{
return n>k?n:k;
}
long long f(long long n)
{
if(n==0)
return 0;
long long x=v[n];
if(x==0)
{
x=max(n,f(n/2)+f(n/3)+f(n/4));
v[n]=x;
}
return x;
}
int main()
{
long long n;
int t=10;
while(t--)
{
cin>>n;
long long a=f(n);
cout<<a<<endl;
}
system ("pause");
return 0;
}