結果

問題 No.1140 EXPotentiaLLL!
ユーザー simansiman
提出日時 2020-08-05 02:32:51
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 281 bytes
コンパイル時間 376 ms
コンパイル使用メモリ 11,248 KB
実行使用メモリ 20,500 KB
最終ジャッジ日時 2023-10-13 06:38:19
合計ジャッジ時間 12,149 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

require 'openssl'

T = gets.to_i
memo = Hash.new

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

  if memo[pv].nil?
    memo[pv] = bn.prime?
  end

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