結果

問題 No.188 HAPPY DAY
ユーザー vabuffvabuff
提出日時 2018-01-17 21:21:46
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 59 ms / 1,000 ms
コード長 785 bytes
コンパイル時間 54 ms
コンパイル使用メモリ 5,248 KB
実行使用メモリ 38,656 KB
最終ジャッジ日時 2024-04-21 02:04:42
合計ジャッジ時間 479 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
38,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* eslint no-console: "off" */

function div_ceil(a, b) {
    return Math.trunc(a/b) + ((((a<0)^(b>0)) && a%b) ? 1 : 0);
}

function div_floor(a, b) {
    return Math.trunc(a/b) + ((((a>0)^(b>0)) && a%b) ? 1 : 0);
}

const DOMS = [
    -1,
    31, 28, 31, 30, 31, 30,
    31, 31, 30, 31, 30, 31,
];

function digit_sum(n) {
    let res = 0;
    while(n > 0) {
        res += n % 10;
        n = div_floor(n, 10);
    }
    return res;
}

function is_ok(m, d) {
    return m == digit_sum(d);
}

function Main(input) {
    let ans = 0;

    for(let m = 1; m <= 12; ++m) {
        let dom = DOMS[m];
        for(let d = 1; d <= dom; ++d) {
            if(is_ok(m,d))
                ++ans;
        }
    }

    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
0