結果

問題 No.1255 ハイレーツ・オブ・ボリビアン
ユーザー 👑 KazunKazun
提出日時 2020-12-14 08:03:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,043 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 81,892 KB
実行使用メモリ 63,540 KB
最終ジャッジ日時 2023-10-20 04:46:49
合計ジャッジ時間 2,525 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,160 KB
testcase_01 AC 41 ms
52,420 KB
testcase_02 AC 46 ms
58,564 KB
testcase_03 AC 45 ms
57,972 KB
testcase_04 AC 47 ms
57,984 KB
testcase_05 AC 53 ms
61,316 KB
testcase_06 AC 54 ms
61,156 KB
testcase_07 AC 55 ms
61,200 KB
testcase_08 AC 109 ms
63,180 KB
testcase_09 AC 116 ms
62,960 KB
testcase_10 AC 113 ms
63,424 KB
testcase_11 AC 110 ms
63,112 KB
testcase_12 AC 116 ms
63,396 KB
testcase_13 WA -
testcase_14 AC 181 ms
60,620 KB
testcase_15 AC 109 ms
63,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#素因数分解
def Prime_Factorization(N):
    if N<0:
        R=[[-1,1]]
    else:
        R=[]

    N=abs(N)
    k=2
    while k*k<=N:
        if N%k==0:
            C=0
            while N%k==0:
                C+=1
                N//=k
            R.append([k,C])
        k+=1

    if N!=1:
        R.append([N,1])
    if not R:
        R.append([N,1])

    return R

#Euler's Totient関数
def Euler_Totient(N):
    N=abs(N)
    if N==1:
        return 1

    H=Prime_Factorization(N)
    R=1
    for (p,e) in H:
        R*=p**(e-1)*(p-1)
    return R

#約数全部
def Divisors(N):
    N=abs(N)
    L,U=[],[]
    k=1
    while k*k <=N:
        if N%k== 0:
            L.append(k)
            if k!=N//k:
                U.append(N//k)
        k+=1
    return L+U[::-1]
#================================================
T=int(input())

for i in range(T):
    N=int(input())
    M=2*N-1

    D=Euler_Totient(M)
    L=Divisors(D)

    ans=-1
    for a in L[::-1]:
        T=pow(2,a,M)
        if T%M==1:
            ans=a
    print(ans)
0