結果

問題 No.405 ローマ数字の腕時計
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-13 16:38:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 604 bytes
コンパイル時間 1,894 ms
コンパイル使用メモリ 72,552 KB
実行使用メモリ 56,544 KB
最終ジャッジ日時 2023-09-21 00:29:46
合計ジャッジ時間 6,302 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,084 KB
testcase_01 AC 121 ms
56,232 KB
testcase_02 AC 122 ms
56,080 KB
testcase_03 AC 120 ms
55,528 KB
testcase_04 AC 119 ms
55,820 KB
testcase_05 AC 119 ms
55,736 KB
testcase_06 AC 123 ms
55,820 KB
testcase_07 AC 121 ms
55,572 KB
testcase_08 AC 121 ms
55,728 KB
testcase_09 AC 120 ms
55,636 KB
testcase_10 AC 120 ms
56,280 KB
testcase_11 AC 121 ms
55,584 KB
testcase_12 AC 121 ms
55,876 KB
testcase_13 AC 122 ms
56,008 KB
testcase_14 AC 121 ms
56,228 KB
testcase_15 AC 123 ms
55,984 KB
testcase_16 AC 122 ms
55,980 KB
testcase_17 AC 122 ms
55,968 KB
testcase_18 AC 122 ms
55,732 KB
testcase_19 AC 121 ms
56,140 KB
testcase_20 AC 122 ms
56,056 KB
testcase_21 AC 124 ms
56,544 KB
testcase_22 AC 120 ms
55,836 KB
testcase_23 AC 120 ms
56,292 KB
testcase_24 AC 120 ms
55,904 KB
testcase_25 AC 123 ms
55,864 KB
testcase_26 AC 120 ms
55,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		int t = sc.nextInt();
		String[] x = {"I","II","III","IIII","V","VI","VII","VIII","IX","X","XI","XII"};
		int time = -101010101;
		for(int i = 0 ; i < x.length ; i++) {
			if(x[i].equals(s1)) {
				time = i + 1;
			}
		}
		if(time + t >= 0) {
			time = (time + t) % 12;
		} else if(time + t < 0) {
			time = 12 - Math.abs((time + t)) % 12;
		}
		if(time == 0) {
			System.out.println("XII");
		} else {
			System.out.println(x[time - 1]);
		}
	}
}
0