結果

問題 No.405 ローマ数字の腕時計
コンテスト
ユーザー くれちー
提出日時 2016-08-10 22:08:45
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 370 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 158 ms
コンパイル使用メモリ 29,768 KB
最終ジャッジ日時 2026-02-23 22:14:30
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%s %d", s, &t);
      |         ^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {
	char s[5], rome[12][5] = { "I","II","III","IIII","V","VI","VII","VIII","IX","X","XI","XII" };
	int a, t, i;

	scanf("%s %d", s, &t);
	if (t < 0) t = 12 - abs(t) % 12;

	for (i = 0; i < 12; i++) {
		if (strcmp(s, rome[i]) == 0) {
			printf("%s\n", rome[(i + t) % 12]);
			break;
		}
	}

	return 0;
}
0