結果

問題 No.1255 ハイレーツ・オブ・ボリビアン
ユーザー 👑 rin204rin204
提出日時 2022-01-27 22:42:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 650 bytes
コンパイル時間 1,720 ms
コンパイル使用メモリ 87,000 KB
実行使用メモリ 76,540 KB
最終ジャッジ日時 2023-08-27 01:06:21
合計ジャッジ時間 4,451 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,664 KB
testcase_01 AC 68 ms
71,640 KB
testcase_02 AC 71 ms
76,212 KB
testcase_03 AC 71 ms
75,724 KB
testcase_04 AC 72 ms
75,604 KB
testcase_05 AC 77 ms
76,540 KB
testcase_06 AC 77 ms
76,360 KB
testcase_07 AC 77 ms
76,216 KB
testcase_08 AC 173 ms
76,484 KB
testcase_09 AC 171 ms
76,396 KB
testcase_10 AC 168 ms
76,248 KB
testcase_11 AC 171 ms
76,340 KB
testcase_12 AC 175 ms
76,504 KB
testcase_13 AC 78 ms
75,840 KB
testcase_14 AC 201 ms
76,492 KB
testcase_15 AC 167 ms
76,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n = 2 * int(input()) - 1
    if n == 1:
        print(1)
        return
    eu = n
    x = n
    for i in range(2, int(n ** 0.5 + 1)):
        if x % i == 0:
            eu *= i - 1
            eu //= i
            while x % i == 0:
                x //= i
    if x != 1:
        eu *= x - 1
        eu //= x
    
    div = []
    for i in range(1, int(n ** 0.5 + 1)):
        if eu % i == 0:
            div.append(i)
            div.append(eu // i)
            
    div.sort()
    
    for i in div:
        if pow(2, i, n) == 1:
            print(i)
            return
    
    
    
for _ in range(int(input())):
    solve()
    
0