結果

問題 No.882 約数倍数
ユーザー megane_anko
提出日時 2021-03-17 00:12:15
言語 TypeScript
(5.7.2)
結果
AC  
実行時間 64 ms / 500 ms
コード長 640 bytes
コンパイル時間 8,101 ms
コンパイル使用メモリ 229,548 KB
実行使用メモリ 39,424 KB
最終ジャッジ日時 2024-12-31 16:34:51
合計ジャッジ時間 9,677 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import * as fs from 'fs';
const input = fs.readFileSync('/dev/stdin', 'utf8');

const ABarray = input.split(' ');
const A = parseInt(ABarray[0]);
const B = parseInt(ABarray[1]);

//約数をぜんぶ配列に入れる関数
function divisor(num:number) {
    let a_results = [];
    for (let i = 1; i <= num; i++) {
        if ((num % i) === 0) {
            a_results.push(i);
        }
    }
    return a_results;
}

//Aの約数をぜんぶ配列に入れる
let r = null;
r = divisor(A);

let answer= 'NO';
for (let j = 0;j < r.length; j++) {
    if (r[j] % B === 0) {
        answer = 'YES';
        break;
    }
}
console.log(answer);
0