-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculatingdartscores.cpp
43 lines (40 loc) · 1.44 KB
/
calculatingdartscores.cpp
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 <bits/stdc++.h>
using namespace std;
string indexToString(int i) {
if(i == 1) return "single";
if(i == 2) return "double";
if(i == 3) return "triple";
}
int main() {
int num;
cin >> num;
for(int i=0;i<21;i++) {
for(int j=0;j<21;j++) {
for(int k=0;k<21;k++) {
for(int l=1;l<4;l++) {
for(int m=1;m<4;m++) {
for(int n=1;n<4;n++) {
int sum = l * i + m * j + n * k;
if(num == sum) {
//cout << sum << endl;
string output = "";
if(l > 0 && i > 0) {
output = output + indexToString(l) + ' ' + to_string(i) + '\n';
}
if(m > 0 && j > 0) {
output = output + indexToString(m) + ' ' + to_string(j) + '\n';
}
if(n > 0 && k > 0) {
output = output + indexToString(n) + ' ' + to_string(k) + '\n';
}
cout << output << endl;
return 0;
}
}
}
}
}
}
}
cout << "Impossible" << endl;
}