結果

問題 No.405 ローマ数字の腕時計
ユーザー yukiteruyukiteru
提出日時 2017-10-11 18:19:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,679 bytes
コンパイル時間 580 ms
コンパイル使用メモリ 77,244 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 00:29:16
合計ジャッジ時間 1,688 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:81:16: 警告: ‘p’ may be used uninitialized [-Wmaybe-uninitialized]
   81 |         if ((p + t) % 12==0) {
      |             ~~~^~~~
main.cpp:23:13: 備考: ‘p’ はここで定義されています
   23 |         int p;
      |             ^

ソースコード

diff #

#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;
}
0