結果

問題 No.1255 ハイレーツ・オブ・ボリビアン
ユーザー chineristACchineristAC
提出日時 2020-10-09 23:19:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 225 ms / 2,000 ms
コード長 697 bytes
コンパイル時間 1,406 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 77,104 KB
最終ジャッジ日時 2023-09-30 14:44:56
合計ジャッジ時間 3,429 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
72,008 KB
testcase_01 AC 75 ms
71,776 KB
testcase_02 AC 84 ms
76,980 KB
testcase_03 AC 79 ms
76,520 KB
testcase_04 AC 81 ms
76,532 KB
testcase_05 AC 88 ms
76,840 KB
testcase_06 AC 85 ms
77,080 KB
testcase_07 AC 87 ms
77,096 KB
testcase_08 AC 179 ms
77,016 KB
testcase_09 AC 182 ms
76,860 KB
testcase_10 AC 187 ms
77,052 KB
testcase_11 AC 177 ms
76,984 KB
testcase_12 AC 184 ms
76,868 KB
testcase_13 AC 87 ms
76,856 KB
testcase_14 AC 225 ms
76,992 KB
testcase_15 AC 179 ms
77,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
def euler_phi(n):
    res=n
    for x in range(2,int(n**.5)+2):
        if n%x==0:
            res=(res//x)*(x-1)
            while n%x==0:
                n//=x
    if n!=1:
        res=(res//n)*(n-1)
    return res

def divisors(M):#Mの約数列 O(n^(0.5+e))
    import math
    d=[]
    i=1
    while math.sqrt(M)>=i:
        if M%i==0:
            d.append(i)
            if i**2!=M:
                d.append(M//i)
        i=i+1
    d.sort()
    return d

for _ in range(int(input())):
    n = int(input())
    d = euler_phi(2*n-1)
    div = divisors(d)
    for i in div:
        if pow(2,i,2*n-1)==1:
            print(i)
            break
    if n==1:
        print(1)
0