-
Notifications
You must be signed in to change notification settings - Fork 0
/
00344.cpp
53 lines (43 loc) · 1.17 KB
/
00344.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
44
45
46
47
48
49
50
51
52
53
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sll pair<string, ll>
vector<sll> conv({
{"M", 1000}, {"CM", 900}, {"D", 500}, {"CD", 400}, {"C", 100}, {"XC", 90}, {"L", 50}, {"XL", 40}, {"X", 10},
{"IX", 9}, {"V", 5}, {"IV", 4}, {"I", 1},
});
string AtoR(ll res){
string temp;
for(auto &[rom, val]: conv){
while(res >= val){
temp += rom;
res -= val;
}
}
return temp;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ll n;
string list[5] = {"I", "V", "X", "L", "C"};
map<string, ll> dp[200];
for(auto x: list) dp[0][x] = 0;
for(ll i = 1; i <= 101; i++){
for(auto x: list) dp[i][x] = dp[i-1][x];
string p = AtoR(i);
// cout << p << "\n";
for(auto x: p) ++(dp[i][string(1, x)]);
}
while(cin >> n && n){
cout << n << ": ";
for(ll i = 0; i < 5; i++){
cout << dp[n][list[i]] << " " << (char) tolower((char)list[i][0]);
if(i!=4) cout << ", ";
}
cout << "\n";
}
return 0;
}