結果

問題 No.405 ローマ数字の腕時計
ユーザー ontama_12ontama_12
提出日時 2016-09-26 15:54:19
言語 JavaScript
(node v21.7.1)
結果
WA  
実行時間 -
コード長 2,034 bytes
コンパイル時間 38 ms
コンパイル使用メモリ 5,248 KB
実行使用メモリ 40,320 KB
最終ジャッジ日時 2024-04-21 01:29:28
合計ジャッジ時間 2,626 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
39,168 KB
testcase_01 AC 65 ms
39,296 KB
testcase_02 AC 67 ms
39,168 KB
testcase_03 AC 66 ms
39,552 KB
testcase_04 AC 66 ms
39,552 KB
testcase_05 AC 68 ms
39,296 KB
testcase_06 AC 64 ms
39,552 KB
testcase_07 AC 63 ms
39,296 KB
testcase_08 WA -
testcase_09 RE -
testcase_10 AC 65 ms
39,296 KB
testcase_11 AC 70 ms
39,296 KB
testcase_12 RE -
testcase_13 AC 71 ms
39,552 KB
testcase_14 AC 65 ms
39,424 KB
testcase_15 WA -
testcase_16 AC 68 ms
39,168 KB
testcase_17 RE -
testcase_18 WA -
testcase_19 AC 64 ms
39,552 KB
testcase_20 AC 65 ms
39,424 KB
testcase_21 AC 65 ms
39,296 KB
testcase_22 AC 65 ms
39,168 KB
testcase_23 AC 67 ms
39,296 KB
testcase_24 AC 64 ms
39,168 KB
testcase_25 RE -
testcase_26 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

    ///////////////////////No.405 ローマ数字の腕時計
    //入力文字読み取り
    process.stdin.resume();
    process.stdin.setEncoding('utf8');
    process.stdin.on('data', function (chunk) {


        //すべて受け取り改行で区切って格納
        var inputall = chunk.split(" ");
        
        timelater = Number(inputall[1]);
        //ローマ数字を一つ一つ分割して解読する
        var romanumber = inputall[0].split("");
        var presentnumber = 0;
        for (var i = 0; i < romanumber.length; i++) {
            if (romanumber[i] == "X") {
                romanumber[i] = 10;
            } else if (romanumber[i] == "V") {
                romanumber[i] = 5;
            } else {
                romanumber[i] = 1;
            }
            presentnumber += romanumber[i];
        }
        if(romanumber[0] ==1 && romanumber[1] ==10){
            presentnumber =9
        }

        //何時間進んだかを計算
        var result = presentnumber + timelater;

        //答えのローマ数字を入れる
        var ans =[]
        if (result <= 12 &&result >=0) {
        }else if(result>12){
            result = Math.floor(result % 12);
        } else {
            while (true) {
                if (result >= 0) {
                    break;
                }
                result += 12
            }
        }

        //ローマ数字に戻して出力
        if (result == 0) {
            ans = "XII"
        } else {
            if (result >= 10) {
                ans.push("X");
                result = result - 10;
            }
            if (result >= 5) {
                ans.push("V");
                result = result - 5;
            }
            if (result > 0) {
                while (true) {
                    if (result == 0) {
                        break;
                    }
                    ans.push("I");
                    result -= 1;
                }
            }
        }
     
        console.log(ans.join(""))
    });
0