結果

問題 No.405 ローマ数字の腕時計
ユーザー cb_4150
提出日時 2017-08-16 23:54:46
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,013 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 56,440 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-13 13:17:15
合計ジャッジ時間 1,359 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

int decode(std::string s) {
	if (s ==    "I") return 1;
	if (s ==   "II") return 2;
	if (s ==  "III") return 3;
	if (s == "IIII") return 4;
	if (s ==    "V") return 5;
	if (s ==   "VI") return 6;
	if (s ==  "VII") return 7;
	if (s == "VIII") return 8;
	if (s ==   "IX") return 9;
	if (s ==    "X") return 10;
	if (s ==   "XI") return 11;
	if (s ==  "XII") return 12;
	return 0;
}

std::string encode(int n) {
	if (n ==  1) return    "I";
	if (n ==  2) return   "II";
	if (n ==  3) return  "III";
	if (n ==  4) return "IIII";
	if (n ==  5) return    "V";
	if (n ==  6) return   "VI";
	if (n ==  7) return  "VII";
	if (n ==  8) return "VIII";
	if (n ==  9) return   "IX";
	if (n == 10) return    "X";
	if (n == 11) return   "XI";
	if (n == 12) return  "XII";
	return "";
}


int main() {
	std::string s;
	int n, t;
	std::cin >> s >> n;
	t = decode(s);

	if (n < 0) {
		n %= 12;
		n += 12;
	}

	t += n;
	if (t > 12) t %= 12;

	std::cout << encode(t) << std::endl;

	return 0;
}
0