結果

問題 No.405 ローマ数字の腕時計
ユーザー fumi6328
提出日時 2018-09-10 22:05:42
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 801 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 56,916 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 19:20:21
合計ジャッジ時間 1,317 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;

int main()
{
    string s;
    int t;
    cin >> s >> t;

    int n = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'I') n++;
        if(s[i] == 'V') n += 5;
        if(s[i] == 'X') n += 10;
    }
    if(s == "IX") n = 9;

    int ans;
    ans = (n + t) % 12;
    while(ans < 0) ans += 12;
    if(ans == 0) ans = 12;

    if(ans < 5){
        for(int i = 0; i < ans; i++)
        cout << 'I';
    }else if(ans < 8){
        cout << 'V';
        for(int i = 0; i < ans % 5; i++)
            cout << 'I';
    }else if(ans == 9)
        cout << "IX";
    else{
        cout << 'X';
        for(int i = 0; i < ans % 10; i++)
        cout << 'I';
    }

    cout << endl;

    return 0;
}
0