結果

問題 No.405 ローマ数字の腕時計
ユーザー eagleeagle
提出日時 2022-06-20 10:26:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 749 bytes
コンパイル時間 2,261 ms
コンパイル使用メモリ 72,128 KB
実行使用メモリ 56,304 KB
最終ジャッジ日時 2023-09-21 00:52:09
合計ジャッジ時間 6,791 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,688 KB
testcase_01 AC 123 ms
56,052 KB
testcase_02 AC 125 ms
55,812 KB
testcase_03 AC 122 ms
55,732 KB
testcase_04 AC 122 ms
56,008 KB
testcase_05 AC 122 ms
56,260 KB
testcase_06 AC 122 ms
56,256 KB
testcase_07 AC 122 ms
55,760 KB
testcase_08 AC 123 ms
56,208 KB
testcase_09 AC 122 ms
56,120 KB
testcase_10 AC 123 ms
55,828 KB
testcase_11 AC 122 ms
55,820 KB
testcase_12 AC 123 ms
56,208 KB
testcase_13 AC 122 ms
55,776 KB
testcase_14 AC 122 ms
55,920 KB
testcase_15 AC 122 ms
55,744 KB
testcase_16 AC 123 ms
55,948 KB
testcase_17 AC 124 ms
55,880 KB
testcase_18 AC 122 ms
56,164 KB
testcase_19 AC 123 ms
55,488 KB
testcase_20 AC 122 ms
56,148 KB
testcase_21 AC 124 ms
55,964 KB
testcase_22 AC 123 ms
55,656 KB
testcase_23 AC 123 ms
56,304 KB
testcase_24 AC 123 ms
56,188 KB
testcase_25 AC 121 ms
55,840 KB
testcase_26 AC 123 ms
56,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String[] timer = {
				"I", "II", "III", "IIII", "V", "VI",
				"VII", "VIII", "IX", "X", "XI", "XII"
		};
		String S1 = sc.next();
		int T = sc.nextInt();
		//現在の時刻を求める
		int time = 0;
		for(int i = 0; i < timer.length; i++) {
			if(S1.equals(timer[i])) {
				time = i;
			}
		}
		//指定された時刻だけ時間を進める
		time += T;
		if(time < 0) {
			while(time < 0) {
				time += 12;
			}
		} else {
			time %= 12;
		}
		//進めた後の時間からローマ数字を求める
		String ans = timer[time];
		System.out.println(ans);
	}
}
0