結果

問題 No.1140 EXPotentiaLLL!
ユーザー kojihashimoto-kobekojihashimoto-kobe
提出日時 2022-05-15 20:22:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,525 ms / 2,000 ms
コード長 447 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 117,556 KB
最終ジャッジ日時 2023-10-11 07:42:53
合計ジャッジ時間 17,419 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,444 ms
117,232 KB
testcase_01 AC 1,430 ms
117,344 KB
testcase_02 AC 1,431 ms
117,476 KB
testcase_03 AC 1,282 ms
117,556 KB
testcase_04 AC 1,054 ms
117,476 KB
testcase_05 AC 1,525 ms
117,408 KB
testcase_06 AC 1,394 ms
117,432 KB
testcase_07 AC 1,502 ms
117,496 KB
testcase_08 AC 352 ms
115,228 KB
testcase_09 AC 343 ms
115,120 KB
testcase_10 AC 334 ms
114,920 KB
testcase_11 AC 336 ms
114,908 KB
testcase_12 AC 334 ms
115,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
#エラトステネスの篩で素数を列挙
x = [0]*(5*10**6+1)
x[1] = 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