結果
問題 |
No.405 ローマ数字の腕時計
|
ユーザー |
![]() |
提出日時 | 2020-01-29 17:19:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 735 bytes |
コンパイル時間 | 1,733 ms |
コンパイル使用メモリ | 176,776 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-16 01:40:38 |
合計ジャッジ時間 | 6,727 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 27 |
コンパイルメッセージ
main.cpp: In function 'int rome2dec(std::string)': main.cpp:33:1: warning: no return statement in function returning non-void [-Wreturn-type] 33 | } | ^
ソースコード
#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]; } } int main() { string s; int t; cin >> s >> t; cout << dec2rome((rome2dec(s) + t + 1199) % 12 + 1) << endl; }