結果

問題 No.405 ローマ数字の腕時計
ユーザー daradara_sanmadaradara_sanma
提出日時 2018-04-30 11:54:20
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 729 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 52,552 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-10 08:22:19
合計ジャッジ時間 1,932 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
4,380 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
using namespace std;

int main() {
	int T1, T2 = 0, i = 0;
	char S1[5], result[5];

	scanf("%s %d",S1, &T1);

	T1 = T1 % 12;
	
	for ( i = 0; i < strlen(S1); i++)
	{
		if (S1 == "IX") {
			T2 = 9;
			break;
		}
		if (S1[i] == 'I') T2++;
		if (S1[i] == 'V') T2 += 5;
		if (S1[i] == 'X') T2 += 10;
	}
	i = 0;

	T2 = (T2 + T1) % 12;
	if (T2 < 0) T2 += 12;

	if (T2 / 10 != 0)
	{
		result[i++] = 'X';
		T2 %= 10;
	}
	if (T2 == 9) {
		printf("IV\n");
		return 0;
	}
	if (T2 / 5 != 0)
	{
		result[i++] = 'V';
		T2 %= 5;
	}
	if (T2 <= 4) {
		for (int k = 0; k < T2; k++)
		{
			result[i++] = 'I';
		}
	}
	result[i] = '\0';

	printf("%s\n", result);

	return 0;
}
0