結果

問題 No.405 ローマ数字の腕時計
ユーザー shinwisteriashinwisteria
提出日時 2017-04-01 09:46:43
言語 Java19
(openjdk 21)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 898 bytes
コンパイル時間 3,296 ms
コンパイル使用メモリ 75,120 KB
実行使用メモリ 56,516 KB
最終ジャッジ日時 2023-09-21 00:25:54
合計ジャッジ時間 7,784 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,516 KB
testcase_01 AC 123 ms
55,700 KB
testcase_02 AC 124 ms
55,740 KB
testcase_03 AC 124 ms
56,256 KB
testcase_04 AC 122 ms
55,816 KB
testcase_05 AC 123 ms
55,832 KB
testcase_06 AC 124 ms
55,824 KB
testcase_07 AC 123 ms
55,936 KB
testcase_08 AC 124 ms
56,040 KB
testcase_09 AC 122 ms
56,252 KB
testcase_10 AC 124 ms
56,080 KB
testcase_11 AC 122 ms
55,780 KB
testcase_12 AC 122 ms
55,748 KB
testcase_13 AC 122 ms
55,708 KB
testcase_14 AC 123 ms
55,892 KB
testcase_15 AC 122 ms
56,176 KB
testcase_16 AC 122 ms
56,516 KB
testcase_17 AC 123 ms
55,908 KB
testcase_18 AC 122 ms
55,936 KB
testcase_19 AC 122 ms
56,024 KB
testcase_20 AC 123 ms
55,772 KB
testcase_21 AC 122 ms
56,260 KB
testcase_22 AC 124 ms
55,560 KB
testcase_23 AC 122 ms
55,960 KB
testcase_24 AC 123 ms
55,788 KB
testcase_25 AC 120 ms
56,432 KB
testcase_26 AC 121 ms
55,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class RomeNumber {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner s = new Scanner(System.in);
		String S1 = s.next();
		int T = s.nextInt(),now = 0;
		s.close();
		if(S1.contains("V")){
			now += 5;
		}else if(S1.contains("X")){
			now += 10;
		}
		if(S1.contains("I")){
			now +=( S1.lastIndexOf("I") - S1.indexOf("I") + 1);
		}
		if(S1.equals("IX")){
			now = 9;
		}
		now += T;
		while(now < 0){
			now += 12;
			//System.out.println(now);
		}
		now %= 12;
		StringBuilder ans = new StringBuilder();
		if(now == 9){
			ans.append("IX");
		}else if(now == 0){
			ans.append("XII");
		}else if(now / 5 == 1){
			ans.append("V");
		}else if(now / 5 == 2){
			ans.append("X");
		}
		if(now != 9 && now != 0){
			for(int i = 0;i < now%5;i++){
				ans.append("I");
			}
		}
		System.out.println(ans);
	}

}
0