結果

問題 No.1140 EXPotentiaLLL!
ユーザー simansiman
提出日時 2020-08-05 02:46:30
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 357 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 11,568 KB
実行使用メモリ 104,860 KB
最終ジャッジ日時 2023-10-13 07:00:17
合計ジャッジ時間 29,798 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 TLE -
testcase_03 TLE -
testcase_04 AC 1,913 ms
85,460 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 1,107 ms
66,412 KB
testcase_09 AC 1,117 ms
66,268 KB
testcase_10 AC 1,104 ms
66,240 KB
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:24: 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

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
      puts 1
    else
      puts 0
    end
  else
    puts -1
  end
end
0