結果

問題 No.405 ローマ数字の腕時計
ユーザー shinwisteriashinwisteria
提出日時 2017-04-01 09:45:25
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 896 bytes
コンパイル時間 3,509 ms
コンパイル使用メモリ 74,716 KB
実行使用メモリ 58,360 KB
最終ジャッジ日時 2023-09-22 01:54:30
合計ジャッジ時間 8,370 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,548 KB
testcase_01 AC 125 ms
55,828 KB
testcase_02 WA -
testcase_03 AC 128 ms
55,812 KB
testcase_04 AC 124 ms
55,984 KB
testcase_05 AC 126 ms
56,396 KB
testcase_06 AC 124 ms
55,888 KB
testcase_07 AC 127 ms
55,608 KB
testcase_08 AC 125 ms
55,752 KB
testcase_09 AC 127 ms
55,712 KB
testcase_10 AC 125 ms
55,492 KB
testcase_11 AC 128 ms
56,260 KB
testcase_12 AC 126 ms
55,556 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 124 ms
56,052 KB
testcase_18 WA -
testcase_19 AC 125 ms
56,108 KB
testcase_20 WA -
testcase_21 AC 125 ms
55,788 KB
testcase_22 WA -
testcase_23 AC 126 ms
56,096 KB
testcase_24 AC 125 ms
55,916 KB
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

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