-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem 31
More file actions
36 lines (30 loc) · 849 Bytes
/
Copy pathproblem 31
File metadata and controls
36 lines (30 loc) · 849 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
/*
n England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation:
1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p).
It is possible to make £2 in the following way:
1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p
How many different ways can £2 be made using any number of coins?
*/
#include <iostream>
using namespace std;
int main() {
int counter = 0;
int p_200 = 200;
for(int a = p_200; a >= 0; a -= 200){
for(int i = a; i >= 0; i-= 100){
for(int j = i; j >= 0; j-= 50){
for(int x = j; x >= 0; x-= 20){
for(int y = x; y >= 0; y-= 10){
for(int z = y; z >= 0; z-= 5){
for(int n = z; n >= 0; n-= 2){
counter++;
}
}
}
}
}
}
}
cout << counter <<endl;
return 0;
}