結果

問題 No.1255 ハイレーツ・オブ・ボリビアン
ユーザー googol_S0googol_S0
提出日時 2020-10-09 23:24:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 208 ms / 2,000 ms
コード長 529 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 76,872 KB
最終ジャッジ日時 2023-09-30 14:45:05
合計ジャッジ時間 3,134 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,588 KB
testcase_01 AC 70 ms
71,868 KB
testcase_02 AC 76 ms
76,128 KB
testcase_03 AC 74 ms
75,712 KB
testcase_04 AC 75 ms
75,776 KB
testcase_05 AC 83 ms
76,808 KB
testcase_06 AC 83 ms
76,748 KB
testcase_07 AC 82 ms
76,480 KB
testcase_08 AC 173 ms
76,652 KB
testcase_09 AC 173 ms
76,540 KB
testcase_10 AC 175 ms
76,620 KB
testcase_11 AC 172 ms
76,660 KB
testcase_12 AC 177 ms
76,872 KB
testcase_13 AC 80 ms
75,992 KB
testcase_14 AC 208 ms
76,636 KB
testcase_15 AC 174 ms
76,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(x):
  r=[]
  for i in range(2,int(x**0.5)+1):
    if x%i==0:
      r.append(i)
      while x%i==0:
        x//=i
  if x!=1:
    r.append(x)
  return r

def g(x):
  r=[]
  for i in range(1,int(x**0.5)+1):
    if x%i==0:
      r.append(i)
      if i*i!=x:
        r.append(x//i)
  return r

T=int(input())
for i in range(T):
  N=int(input())
  N=2*N-1
  X=f(N)
  Y=N
  for j in range(len(X)):
    Y//=X[j]
    Y*=X[j]-1
  X=g(Y)
  P=10**12
  for j in range(len(X)):
    if pow(2,X[j],N)==(1%N):
      P=min(P,X[j])
  print(P)
0