-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHit the Lottery.cpp
More file actions
43 lines (41 loc) · 802 Bytes
/
Hit the Lottery.cpp
File metadata and controls
43 lines (41 loc) · 802 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
#include <iostream>
using namespace std;
int main()
{
int money, temp, count = 0; // 1, 5, 10, 20, 100
cin >> money;
while (1)
{
if (money >= 100)
{
temp = money / 100;
count += temp;
money %= 100;
}
else if (money >= 20)
{
temp = money / 20;
count += temp;
money %= 20;
}
else if (money >= 10)
{
temp = money / 10;
count += temp;
money %= 10;
}
else if (money >= 5)
{
temp = money / 5;
count += temp;
money %= 5;
}
else
{
count += money;
break;
}
}
cout << count << endl;
return 0;
}