結果

問題 No.207 世界のなんとか
ユーザー vabuffvabuff
提出日時 2018-01-17 22:20:14
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 71 ms / 5,000 ms
コード長 874 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 6,940 KB
実行使用メモリ 40,064 KB
最終ジャッジ日時 2024-04-21 02:05:36
合計ジャッジ時間 2,565 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
39,808 KB
testcase_01 AC 67 ms
39,424 KB
testcase_02 AC 70 ms
39,936 KB
testcase_03 AC 70 ms
39,552 KB
testcase_04 AC 69 ms
39,936 KB
testcase_05 AC 70 ms
39,680 KB
testcase_06 AC 67 ms
39,552 KB
testcase_07 AC 66 ms
39,552 KB
testcase_08 AC 68 ms
39,680 KB
testcase_09 AC 68 ms
39,680 KB
testcase_10 AC 71 ms
39,936 KB
testcase_11 AC 70 ms
39,680 KB
testcase_12 AC 71 ms
40,064 KB
testcase_13 AC 71 ms
39,808 KB
testcase_14 AC 71 ms
39,808 KB
testcase_15 AC 69 ms
39,552 KB
testcase_16 AC 65 ms
39,424 KB
testcase_17 AC 67 ms
39,552 KB
testcase_18 AC 62 ms
39,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

let assert = require("assert");

function tokens(s) {
    return s.trim().split(/\s+/);
}

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);
}

function digits(n) {
    assert(n >= 0);

    if(n == 0) return [0];

    let res = [];
    while(n > 0) {
        res.push(n % 10);
        n = div_floor(n, 10);
    }
    return res;
}

function TO_INT(s) {
    return parseInt(s, 10);
}

function is_ok(n) {
    if(n % 3 == 0) return true;

    return digits(n).includes(3);
}

function Main(input) {
    let [A, B] = tokens(input).map(s => TO_INT(s));

    for(let i = A; i <= B; ++i) {
        if(is_ok(i)) {
            console.log(i);
        }
    }
}

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