結果

問題 No.1140 EXPotentiaLLL!
ユーザー kojihashimoto-kobekojihashimoto-kobe
提出日時 2022-05-15 20:20:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 438 bytes
コンパイル時間 710 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 117,684 KB
最終ジャッジ日時 2023-10-11 07:39:51
合計ジャッジ時間 17,204 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,459 ms
117,436 KB
testcase_01 AC 1,459 ms
117,448 KB
testcase_02 AC 1,472 ms
117,684 KB
testcase_03 AC 1,274 ms
117,636 KB
testcase_04 AC 1,044 ms
117,476 KB
testcase_05 AC 1,479 ms
117,568 KB
testcase_06 WA -
testcase_07 AC 1,508 ms
117,576 KB
testcase_08 AC 345 ms
115,176 KB
testcase_09 AC 346 ms
115,184 KB
testcase_10 AC 349 ms
115,096 KB
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
#エラトステネスの篩で素数を列挙
x = [0]*(5*10**6+1)
for i in range(2,5*10**6+1):
  if x[i] == 0:
    I = i
    j = 2
    while I*j <= 5*10**6:
      x[I*j] = 1
      j += 1

for _ in range(t):
  a,p = map(int, input().split())
  if x[p] == 1:
    print(-1)
  else:
    #aがpの倍数なら当然答えは0
    if a%p == 0:
      print(0)
    else:
      #フェルマーの定理に注目
      print(1)
0