結果
| 問題 |
No.405 ローマ数字の腕時計
|
| コンテスト | |
| ユーザー |
yukiteru
|
| 提出日時 | 2017-10-11 18:19:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,679 bytes |
| コンパイル時間 | 553 ms |
| コンパイル使用メモリ | 78,092 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-06 19:13:47 |
| 合計ジャッジ時間 | 1,270 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:81:16: warning: 'p' may be used uninitialized [-Wmaybe-uninitialized]
81 | if ((p + t) % 12==0) {
| ~~~^~~~
main.cpp:23:13: note: 'p' was declared here
23 | int p;
| ^
ソースコード
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
using namespace std;
int main(void) {
string s;
int p;
int t;
int q;
cin >> s;
cin >> t;
if (s[0] == 'I') {
if (s[1] == 'I') {
if (s[2] == 'I') {
if (s[3] == 'I') {
p = 4;
}
else {
p = 3;
}
}
else {
p = 2;
}
}
else if (s[1] == 'X') {
p = 9;
}
else {
p = 1;
}
}
else if (s[0] == 'V') {
if (s[1] == 'I') {
if (s[2] == 'I') {
if (s[3] == 'I') {
p = 8;
}
else {
p = 7;
}
}
else {
p = 6;
}
}
else {
p = 5;
}
}
else if (s[0] == 'X') {
if (s[1] == 'I') {
if (s[2] == 'I') {
p = 12;
}
else {
p = 11;
}
}
else {
p = 10;
}
}
if ((p + t) % 12==0) {
q = 12;
}
else if((p + t) % 12 > 0){
q = (p + t) % 12;
}
else {
q = 12 - abs((p + t) % 12);
}
switch (q) {
case 1:
cout << "I" << endl;
break;
case 2:
cout << "II" << endl;
break;
case 3:
cout << "III" << endl;
break;
case 4:
cout << "IIII" << endl;
break;
case 5:
cout << "V" << endl;
break;
case 6:
cout << "VI" << endl;
break;
case 7:
cout << "VII" << endl;
break;
case 8:
cout << "VIII" << endl;
break;
case 9:
cout << "IX" << endl;
break;
case 10:
cout << "X" << endl;
break;
case 11:
cout << "XI" << endl;
break;
case 12:
cout << "XII" << endl;
break;
}
return 0;
}
yukiteru