結果

問題 No.1140 EXPotentiaLLL!
ユーザー simansiman
提出日時 2020-08-05 02:47:52
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 383 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 11,220 KB
実行使用メモリ 110,444 KB
最終ジャッジ日時 2023-10-13 07:01:19
合計ジャッジ時間 29,281 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 TLE -
testcase_03 TLE -
testcase_04 AC 1,883 ms
89,288 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 1,116 ms
66,548 KB
testcase_09 AC 1,119 ms
66,244 KB
testcase_10 AC 1,127 ms
66,248 KB
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ans = []

STDIN.readlines.each do |line|
  a, pv = line.split.map(&:to_i)

  break if a.nil?

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

puts ans
0