結果

問題 No.882 約数倍数
ユーザー wipexwipex
提出日時 2019-09-15 22:59:52
言語 Ruby
(3.3.0)
結果
AC  
実行時間 92 ms / 500 ms
コード長 455 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 11,352 KB
実行使用メモリ 15,356 KB
最終ジャッジ日時 2023-09-21 04:15:46
合計ジャッジ時間 2,911 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
15,352 KB
testcase_01 AC 89 ms
15,184 KB
testcase_02 AC 92 ms
15,300 KB
testcase_03 AC 91 ms
15,336 KB
testcase_04 AC 90 ms
15,216 KB
testcase_05 AC 90 ms
15,252 KB
testcase_06 AC 90 ms
15,208 KB
testcase_07 AC 90 ms
15,076 KB
testcase_08 AC 88 ms
15,356 KB
testcase_09 AC 90 ms
15,336 KB
testcase_10 AC 91 ms
15,184 KB
testcase_11 AC 92 ms
15,084 KB
testcase_12 AC 90 ms
15,132 KB
testcase_13 AC 91 ms
15,168 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

@flg =0

# coding: utf-8                                                                          
require 'prime'
a,b = gets.chomp.split(" ").map(&:to_i)

def divisors(n)
  n.prime_division.inject([1]) do |ary, (p, e)|
    (0..e).map{ |e1| p ** e1
    }.product(ary).map{ |a, b| a * b }
  end.sort
end

divisors(a).each do |num|
  if (num%b) == 0
    @flg =1
    break
  else
    @flg =0
    next
  end
end

if @flg ==1
  puts "YES"
else
  puts "NO"
end
0