結果

問題 No.1140 EXPotentiaLLL!
ユーザー simansiman
提出日時 2020-08-05 02:42:45
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 318 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 11,232 KB
実行使用メモリ 66,524 KB
最終ジャッジ日時 2023-10-13 06:53:31
合計ジャッジ時間 27,107 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 TLE -
testcase_03 AC 1,929 ms
66,484 KB
testcase_04 AC 1,764 ms
66,276 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 1,104 ms
66,384 KB
testcase_09 AC 1,103 ms
66,492 KB
testcase_10 AC 1,091 ms
66,524 KB
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:22: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

require 'prime'

T = gets.to_i
MAX_P = 5 * 10 ** 6
is_prime = Array.new(MAX_P + 1, false)
is_prime[1] = true

Prime.each(MAX_P) do |n|
  is_prime[n] = true
end

T.times do
  a, pv = gets.split.map(&:to_i)

  if is_prime[pv]
    if a.gcd(pv) == 1
      puts 1
    else
      puts 0
    end
  else
    puts -1
  end
end
0