結果

問題 No.432 占い(Easy)
ユーザー testtest
提出日時 2022-11-24 06:04:02
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 677 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 5,152 KB
実行使用メモリ 43,368 KB
最終ジャッジ日時 2023-10-25 22:50:44
合計ジャッジ時間 5,885 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
37,376 KB
testcase_01 AC 65 ms
37,344 KB
testcase_02 AC 67 ms
37,352 KB
testcase_03 AC 68 ms
37,372 KB
testcase_04 AC 128 ms
41,624 KB
testcase_05 AC 68 ms
37,420 KB
testcase_06 AC 70 ms
37,532 KB
testcase_07 AC 76 ms
41,528 KB
testcase_08 AC 68 ms
37,416 KB
testcase_09 AC 87 ms
38,408 KB
testcase_10 AC 80 ms
41,604 KB
testcase_11 AC 93 ms
42,916 KB
testcase_12 AC 152 ms
42,716 KB
testcase_13 AC 152 ms
42,716 KB
testcase_14 AC 93 ms
42,920 KB
testcase_15 AC 68 ms
37,428 KB
testcase_16 AC 66 ms
37,428 KB
testcase_17 AC 128 ms
42,700 KB
testcase_18 AC 120 ms
43,364 KB
testcase_19 AC 108 ms
43,368 KB
testcase_20 AC 96 ms
42,908 KB
testcase_21 AC 98 ms
43,036 KB
testcase_22 AC 72 ms
37,796 KB
testcase_23 AC 78 ms
37,996 KB
testcase_24 AC 85 ms
38,404 KB
testcase_25 AC 85 ms
38,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function fortuneTelling(s) {
    while (s.length > 1) {
        let x = "";
        for (let i = 0; i < s.length - 1; i++) {
            let a = s.slice(i, i + 2);
            let b = (parseInt(a[0]) + parseInt(a[1]));
            if (b >= 10) {
                let c = b.toString();
                x += (parseInt(c[0]) + parseInt(c[1]));
            } else {
                x += b;
            }
        }
        s = x
    }
    return s
}
function Main(input) {
    const src = input.split("\n");
    const n = parseInt(src[0]);
    for (let i = 1; i <= n; i++) {
        console.log(fortuneTelling(src[i]));
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
0