結果

問題 No.405 ローマ数字の腕時計
ユーザー daradara_sanma
提出日時 2018-04-30 12:04:11
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 764 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 54,740 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-27 23:50:27
合計ジャッジ時間 1,303 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15 WA * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%s %d",S1, &T1);
      |         ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

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;
	if (S1[0] == 'I' && S1[1] == 'X')
	{
		printf("In");
		T2 = 9;
	}
	else
	{
		for (int k = 0; k < strlen(S1); k++)
		{
			if (S1[k] == 'I') T2++;
			if (S1[k] == 'V') T2 += 5;
			if (S1[k] == 'X') T2 += 10;
		}
	}



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

	if (T2 / 10 != 0)
	{
		result[i++] = 'X';
		T2 %= 10;
	}
	if (T2 == 9) {
		printf("IX\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