結果

問題 No.1255 ハイレーツ・オブ・ボリビアン
ユーザー tamatotamato
提出日時 2020-10-10 00:20:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 1,145 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 87,440 KB
実行使用メモリ 76,724 KB
最終ジャッジ日時 2023-09-30 14:46:02
合計ジャッジ時間 3,026 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,572 KB
testcase_01 AC 72 ms
71,812 KB
testcase_02 AC 76 ms
75,860 KB
testcase_03 AC 76 ms
75,844 KB
testcase_04 AC 76 ms
76,048 KB
testcase_05 AC 83 ms
76,288 KB
testcase_06 AC 81 ms
76,508 KB
testcase_07 AC 81 ms
76,520 KB
testcase_08 AC 172 ms
76,212 KB
testcase_09 AC 169 ms
76,388 KB
testcase_10 AC 173 ms
76,280 KB
testcase_11 AC 172 ms
76,380 KB
testcase_12 AC 173 ms
76,724 KB
testcase_13 AC 82 ms
76,040 KB
testcase_14 AC 224 ms
76,476 KB
testcase_15 AC 173 ms
76,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    def PrimeDecomposition(N):
        ret = {}
        n = int(N ** 0.5)
        for d in range(2, n + 1):
            while N % d == 0:
                if d not in ret:
                    ret[d] = 1
                else:
                    ret[d] += 1
                N //= d
            if N == 1:
                break
        if N != 1:
            ret[N] = 1
        return ret

    def euler_phi(N):
        P = PrimeDecomposition(N)
        ret = N
        for p in P:
            ret = ret * (p-1) // p
        return ret

    for _ in range(int(input())):
        N = int(input())
        if N == 1:
            print(1)
            continue
        phi = euler_phi(2 * N - 1)
        div = []
        for i in range(1, phi + 1):
            if i * i > phi:
                break
            if phi % i == 0:
                div.append(i)
                div.append(phi // i)
        div.sort()
        for d in div:
            if pow(2, d, 2*N-1) == 1:
                print(d)
                break


if __name__ == '__main__':
    main()
0