-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeup 3301.cpp
More file actions
74 lines (67 loc) · 1.14 KB
/
Copy pathcodeup 3301.cpp
File metadata and controls
74 lines (67 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
72
73
74
#include <iostream>
using namespace std;
int function(int target, int increase)
{
if (target != 0)
{
if (target - 50000 >= 0)
{
target = target - 50000;
increase++;
return function(target, increase);
}
else if (target - 10000 >= 0)
{
target = target - 10000;
increase++;
return function(target, increase);
}
else if (target - 5000 >= 0)
{
target = target - 5000;
increase++;
return function(target, increase);
}
else if (target - 1000 >= 0)
{
target = target - 1000;
increase++;
return function(target, increase);
}
else if (target - 500 >= 0)
{
target = target - 500;
increase++;
return function(target, increase);
}
else if (target - 100 >= 0)
{
target = target - 100;
increase++;
return function(target, increase);
}
else if (target - 50 >= 0)
{
target = target - 50;
increase++;
return function(target, increase);
}
else
{
target = target - 10;
increase++;
return function(target, increase);
}
}
else
{
return increase;
}
}
int main()
{
int target;
int increase = 0;
cin >> target;
cout << function(target, increase) << endl;
}