結果
問題 |
No.405 ローマ数字の腕時計
|
ユーザー |
![]() |
提出日時 | 2020-01-29 17:21:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 751 bytes |
コンパイル時間 | 1,587 ms |
コンパイル使用メモリ | 176,444 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-06 19:26:24 |
合計ジャッジ時間 | 2,376 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
#include <bits/stdc++.h> using namespace std; string dec2rome(int n) { string ans; int rep; if (n <= 4) { rep = n; } else if (n <= 8) { ans = "V"; rep = n - 5; } else if (n == 9) { return "IX"; } else { ans = "X"; rep = n - 10; } for (int i = 0; i < rep; i++) ans += "I"; return ans; } int rome2dec(string s) { map<char, int> m; m['I'] = 1; m['V'] = 5; m['X'] = 10; int ans = 0, prev = 0; for (char c : s) { ans += m[c]; if (m[c] > prev) ans -= 2 * prev; prev = m[c]; } return ans; } int main() { string s; int t; cin >> s >> t; cout << dec2rome((rome2dec(s) + t + 1199) % 12 + 1) << endl; }