-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuva344.cpp
More file actions
84 lines (61 loc) · 1.36 KB
/
uva344.cpp
File metadata and controls
84 lines (61 loc) · 1.36 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
75
76
77
78
79
80
81
82
83
84
#include <cstdio>
#include <cstring>
const int MAXN = 101;
int rc[MAXN][5];
int rv[5] = {1, 5, 10, 50, 100};
void create_rc() {
memset(rc, 0, sizeof(rc));
for(int i = 1; i < MAXN; ++i) {
int tv = i;
if(tv == 100) {
rc[i][4] = 1;
tv -= 100;
}
if(tv/10 == 9) {
rc[i][2] = 1;
rc[i][4] = 1;
tv -= 90;
}
if(tv/10 == 4) {
rc[i][2] = 1;
rc[i][3] = 1;
tv -= 40;
}
if(tv >= 50) {
rc[i][3] += 1;
tv -= 50;
}
if(tv >= 10) {
int k = tv / 10;
rc[i][2] = k;
tv %= 10;
}
if(tv == 4) {
rc[i][0] += 1;
rc[i][1] += 1;
tv -= 4;
}
if(tv == 9) {
rc[i][0] += 1;
rc[i][2] += 1;
tv -= 9;
}
if(tv >= 5) {
rc[i][1] += 1;
tv -= 5;
}
rc[i][0] += tv;
for(int j = 0; j < 5; ++j) {
rc[i][j] += rc[i-1][j];
}
}
}
int main() {
// freopen("input.txt", "r", stdin);
create_rc();
int n;
while(scanf("%d", &n) != EOF && n != 0) {
printf("%d: %d i, %d v, %d x, %d l, %d c\n", n, rc[n][0], rc[n][1], rc[n][2], rc[n][3], rc[n][4]);
}
return 0;
}