結果

問題 No.405 ローマ数字の腕時計
ユーザー btk
提出日時 2016-08-04 10:56:32
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 529 bytes
コンパイル時間 1,564 ms
コンパイル使用メモリ 169,460 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-06 18:56:45
合計ジャッジ時間 2,436 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

int convert(string s){
    if(s=="IX")return 8;
    int res=0;
    for(auto &it:s){
        if(it=='I')res++;
        if(it=='V')res+=5;
        if(it=='X')res+=10;
    }
    return (res+11)%12;
}

string convert(int x){
    x++;
    if(x==9)return "IX";
    string res;
    if(x>=10)res+="X",x-=10;
    if(x>=5)res+="V",x-=5;
    while(x--)res+="I";
    return res;
}
int main(){
    string s;int T;
    cin>>s>>T;
    cout<<convert((convert(s)+T%12+12)%12)<<endl;
    return 0;
}
0