結果
| 問題 |
No.405 ローマ数字の腕時計
|
| ユーザー |
|
| 提出日時 | 2016-08-05 22:45:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,225 bytes |
| コンパイル時間 | 1,320 ms |
| コンパイル使用メモリ | 159,708 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-06 18:59:47 |
| 合計ジャッジ時間 | 1,827 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:38:13: warning: ‘b’ may be used uninitialized in this function [-Wmaybe-uninitialized]
38 | if(12>=a+b){
| ~^~
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
string s1;
int t,a,b,c,p;
cin>>s1>>t;
p=1;
if(t<0) p=-1;
a=abs(t)%12;
if(s1=="I"){
b=1;
} else if(s1=="II"){
b=2;
} else if(s1=="III"){
b=3;
} else if(s1=="IIII"){
b=4;
} else if(s1=="V"){
b=5;
} else if(s1=="VI"){
b=6;
} else if(s1=="VII"){
b=7;
} else if(s1=="VIII"){
b=8;
} else if(s1=="IX"){
b=9;
} else if(s1=="X"){
b=10;
} else if(s1=="XI"){
b=11;
} else if(s1=="XII"){
b=12;
}
if(p==1){
if(12>=a+b){
c=a+b;
} else {
c=a+b-12;
}
} else if(p==-1){
if(0<b-a){
c=b-a;
} else {
c=b-a+12;
}
}
if(c==1){
cout<<"I"<<endl;
} else if(c==2){
cout<<"II"<<endl;
} else if(c==3){
cout<<"III"<<endl;
} else if(c==4){
cout<<"IIII"<<endl;
} else if(c==5){
cout<<"V"<<endl;
} else if(c==6){
cout<<"VI"<<endl;
} else if(c==7){
cout<<"VII"<<endl;
} else if(c==8){
cout<<"VIII"<<endl;
} else if(c==9){
cout<<"IX"<<endl;
} else if(c==10){
cout<<"X"<<endl;
} else if(c==11){
cout<<"XI"<<endl;
} else if(c==12){
cout<<"XII"<<endl;
}
return 0;
}