結果

問題 No.1255 ハイレーツ・オブ・ボリビアン
ユーザー googol_S0
提出日時 2020-10-09 23:24:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 166 ms / 2,000 ms
コード長 529 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 82,272 KB
実行使用メモリ 64,092 KB
最終ジャッジ日時 2024-07-23 08:45:57
合計ジャッジ時間 2,178 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

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