結果

問題 No.405 ローマ数字の腕時計
コンテスト
ユーザー asdfghjkl;
提出日時 2020-03-20 19:17:08
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 932 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 206 ms
コンパイル使用メモリ 42,484 KB
最終ジャッジ日時 2026-02-22 05:29:57
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void){
char s[10];
int t;
int now=0;
scanf("%s",s);
scanf("%d",&t);
for(int i=0;s[i]!='\0';i++){
if(s[0]=='I'&&s[1]=='X'){now=9;break;}
else{
    if(s[i]=='I'){now++;}
    else if(s[i]=='V'){now=now+5;}
    else{now=now+10;}
}
}

now=now+t;

for(;;){
    if(now<0){now=now+24;}
    else if(now>24){now=now-24;}
    else{break;}
}

if(now==0||now==24||now==12){printf("XII\n");}
else if(now==1||now==13){printf("I\n");}
else if(now==2||now==14){printf("II\n");}
else if(now==3||now==15){printf("III\n");}
else if(now==4||now==16){printf("IIII\n");}
else if(now==5||now==17){printf("V\n");}
else if(now==6||now==18){printf("VI\n");}
else if(now==7||now==19){printf("VII\n");}
else if(now==8||now==20){printf("VIII\n");}
else if(now==9||now==21){printf("IX\n");}
else if(now==10||now==22){printf("X\n");}
else if(now==11||now==23){printf("XI\n");}



}
0