結果
| 問題 |
No.405 ローマ数字の腕時計
|
| ユーザー |
okayunonaha
|
| 提出日時 | 2016-08-05 23:26:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,508 bytes |
| コンパイル時間 | 435 ms |
| コンパイル使用メモリ | 55,900 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-06 19:00:24 |
| 合計ジャッジ時間 | 1,272 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%s %d", s, &t);
| ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int solve(char *str, int t);
int main(void) {
int t,n=0;
char s[5];
scanf("%s %d", s, &t);
s[strlen(s)] = '\0';
n = solve(s, t);
//cout << n << endl;
if(n < 0) n = n%12+12;
if(n == 0) {
cout << "XII"<< endl;
} else if(n == 1) {
cout << "I"<<endl;
} else if(n == 2) {
cout << "II"<<endl;
} else if(n == 3) {
cout << "III"<<endl;
} else if(n == 4) {
cout << "IIII"<<endl;
} else if(n == 5) {
cout<< "V"<<endl;
} else if(n == 6) {
cout<< "VI"<<endl;
} else if(n == 7) {
cout<< "VII"<<endl;
} else if(n == 8) {
cout<< "VIII"<<endl;
} else if(n == 9) {
cout<< "IX"<<endl;
} else if(n == 10) {
cout<< "X"<<endl;
}else if(n == 11) {
cout << "XI"<< endl;
}
return 0;
}
int solve(char *str, int t) {
int n = 0;
if (str[0] == 'I'&&str[1]=='\0') {
n += 1+t;
}else if(!strcmp(str,"II")) {
n += 2+t;
}else if(!strcmp(str, "III")) {
n += 3+t;
}else if (!strcmp(str, "IIII")) {
n += 4+t;
}else if(str[0] == 'V'&&str[1]=='\0') {
n += 5+t;
}else if(!strcmp(str, "VI")) {
n += 6+t;
}else if(!strcmp(str,"VII")) {
n += 7+t;
}else if(!strcmp(str,"VIII")) {
n += 8+t;
}else if(!strcmp(str,"IX")) {
n += 9+t;
}else if(str[0] == 'X'&& str[1] =='\0') {
n += 10+t;
}else if(!strcmp(str,"XI")) {
n += 11+t;
}else if(!strcmp(str, "XII")) {
n += 12+t;
}
n %= 12;
return n;
}
okayunonaha