-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecursiveFunction.cpp
More file actions
71 lines (35 loc) · 1.14 KB
/
Copy pathrecursiveFunction.cpp
File metadata and controls
71 lines (35 loc) · 1.14 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
#include <stdio.h>
using namespace std;
unsigned long long int arraySize=(1000000000/6)+1;
unsigned long long int memoArray[1000000000/6+1];
unsigned long long int findMax(unsigned long long int param1, unsigned long long int param2,unsigned long long int* amount)
{
//base case
if(param1>=param2 )
{
(*amount)+=param1;
return 0;
}
else
{
param2=param1/2;
unsigned long long int param3=param1/3;
unsigned long long int param4=param1/4;
return findMax(param2,param2/2+param2/3+param2/4,amount) + findMax(param3,param3/2+param3/3+param3/4,amount) + findMax(param4,param4/2+param4/3+param4/4,amount);
}
}
int main()
{
unsigned long long int currentValue=0;
while (scanf("%llu",¤tValue) != EOF)
{
unsigned long long int amount=0;
findMax(currentValue,currentValue/2+currentValue/3+currentValue/4,&amount);
cout<<amount<<endl;
}
return 0;
}