結果

問題 No.358 も~っと!門松列
ユーザー indiana_shima7indiana_shima7
提出日時 2016-04-23 17:28:23
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 75 ms / 1,000 ms
コード長 911 bytes
コンパイル時間 54 ms
コンパイル使用メモリ 6,684 KB
実行使用メモリ 41,580 KB
最終ジャッジ日時 2024-04-21 01:18:24
合計ジャッジ時間 2,700 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.replace(/\n/g, '').split(" ");
//console.log(arr);
var a1 = parseInt(arr[0]);
var a2 = parseInt(arr[1]);
var a3 = parseInt(arr[2]);

var max = Math.max(Math.max(a1, a2), a3);
var b1,b2,b3;
var count = 0;

var isMonmatsu = function(n1, n2, n3) {
        if (n1 !== n2 && n1 !== n3 && n2 !== n3) {
                if (n1 > n2 && n3 > n2) {
                        return true;
                } else if (n1 < n2 && n3 < n2) {
                        return true;
                }
        }
        return false;

}

if (isMonmatsu(a1, a2, a3)) {
        console.log("INF");
        process.exit();
}
for (var i = 1; i <= max; i++) {
        b1 = a1 % i;
        b2 = a2 % i;
        b3 = a3 % i;
        if (isMonmatsu(b1, b2, b3)) {
                //console.log(b1, b2, b3);
                count++;
        }
}

console.log(count);
0