結果

問題 No.1255 ハイレーツ・オブ・ボリビアン
ユーザー tktk_snsntktk_snsn
提出日時 2021-04-24 15:28:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 210 ms / 2,000 ms
コード長 726 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 76,828 KB
最終ジャッジ日時 2023-09-17 13:37:37
合計ジャッジ時間 3,171 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,596 KB
testcase_01 AC 75 ms
71,736 KB
testcase_02 AC 80 ms
75,952 KB
testcase_03 AC 81 ms
76,584 KB
testcase_04 AC 80 ms
75,936 KB
testcase_05 AC 84 ms
76,472 KB
testcase_06 AC 86 ms
76,828 KB
testcase_07 AC 83 ms
76,560 KB
testcase_08 AC 172 ms
76,420 KB
testcase_09 AC 174 ms
76,660 KB
testcase_10 AC 174 ms
76,504 KB
testcase_11 AC 171 ms
76,504 KB
testcase_12 AC 178 ms
76,500 KB
testcase_13 AC 83 ms
76,500 KB
testcase_14 AC 210 ms
76,420 KB
testcase_15 AC 172 ms
76,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def euler_phi(N):
    """
    Euler totient function
    [1,N]の自然数のうちNと互いに素なものの個数
    """
    res = N
    for i in range(2, int(N ** 0.5) + 1):
        if N % i == 0:
            res -= res // i
            while N % i == 0:
                N //= i
    if N > 1:
        res -= res // N
    return res


def div(n):
    res = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            res.add(i)
            res.add(n//i)
    return sorted(res)


def main():
    N = int(input())
    if N == 1:
        return 1
    mod = 2*N-1
    for i in div(euler_phi(mod)):
        if pow(2, i, mod) == 1:
            return i


T = int(input())
for _ in range(T):
    print(main())
0