結果

問題 No.1312 Snake Eyes
ユーザー roarisroaris
提出日時 2020-12-09 01:11:08
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 753 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 80,928 KB
最終ジャッジ日時 2023-10-19 02:41:17
合計ジャッジ時間 12,692 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
69,976 KB
testcase_01 AC 61 ms
75,112 KB
testcase_02 AC 64 ms
75,252 KB
testcase_03 AC 39 ms
53,512 KB
testcase_04 AC 39 ms
53,512 KB
testcase_05 AC 54 ms
69,976 KB
testcase_06 AC 59 ms
75,112 KB
testcase_07 AC 51 ms
69,976 KB
testcase_08 AC 62 ms
75,124 KB
testcase_09 AC 52 ms
69,976 KB
testcase_10 AC 65 ms
75,256 KB
testcase_11 AC 59 ms
75,112 KB
testcase_12 AC 64 ms
75,256 KB
testcase_13 AC 67 ms
75,248 KB
testcase_14 AC 88 ms
75,276 KB
testcase_15 AC 65 ms
75,244 KB
testcase_16 AC 64 ms
75,252 KB
testcase_17 AC 75 ms
75,268 KB
testcase_18 AC 66 ms
75,256 KB
testcase_19 AC 62 ms
75,124 KB
testcase_20 AC 65 ms
75,252 KB
testcase_21 AC 68 ms
75,248 KB
testcase_22 AC 51 ms
69,976 KB
testcase_23 AC 140 ms
75,672 KB
testcase_24 AC 75 ms
75,300 KB
testcase_25 AC 64 ms
75,292 KB
testcase_26 AC 69 ms
75,284 KB
testcase_27 AC 63 ms
75,284 KB
testcase_28 AC 85 ms
75,308 KB
testcase_29 AC 64 ms
75,288 KB
testcase_30 AC 112 ms
75,332 KB
testcase_31 AC 95 ms
75,324 KB
testcase_32 AC 77 ms
75,304 KB
testcase_33 AC 52 ms
70,012 KB
testcase_34 AC 86 ms
75,308 KB
testcase_35 AC 65 ms
75,284 KB
testcase_36 AC 95 ms
75,320 KB
testcase_37 AC 86 ms
75,308 KB
testcase_38 AC 169 ms
75,748 KB
testcase_39 AC 83 ms
75,444 KB
testcase_40 AC 66 ms
75,420 KB
testcase_41 AC 134 ms
75,744 KB
testcase_42 AC 65 ms
75,428 KB
testcase_43 AC 77 ms
75,444 KB
testcase_44 AC 77 ms
75,444 KB
testcase_45 AC 66 ms
75,420 KB
testcase_46 AC 77 ms
75,448 KB
testcase_47 AC 55 ms
70,208 KB
testcase_48 AC 482 ms
75,964 KB
testcase_49 AC 179 ms
75,752 KB
testcase_50 AC 107 ms
75,604 KB
testcase_51 AC 100 ms
75,476 KB
testcase_52 AC 92 ms
75,444 KB
testcase_53 AC 138 ms
75,752 KB
testcase_54 AC 110 ms
75,476 KB
testcase_55 AC 83 ms
75,448 KB
testcase_56 AC 325 ms
75,756 KB
testcase_57 AC 85 ms
75,444 KB
testcase_58 AC 148 ms
75,920 KB
testcase_59 AC 174 ms
75,756 KB
testcase_60 AC 73 ms
75,424 KB
testcase_61 AC 147 ms
75,748 KB
testcase_62 AC 140 ms
75,748 KB
testcase_63 AC 78 ms
75,448 KB
testcase_64 AC 95 ms
75,428 KB
testcase_65 AC 66 ms
75,392 KB
testcase_66 AC 135 ms
75,664 KB
testcase_67 AC 88 ms
75,304 KB
testcase_68 AC 67 ms
75,428 KB
testcase_69 AC 88 ms
75,444 KB
testcase_70 AC 214 ms
75,756 KB
testcase_71 AC 140 ms
75,744 KB
testcase_72 AC 132 ms
75,716 KB
testcase_73 AC 76 ms
75,448 KB
testcase_74 AC 70 ms
75,296 KB
testcase_75 AC 75 ms
75,412 KB
testcase_76 TLE -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def make_divs(n):
    divs = []
    
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            divs.append(i)
            
            if i!=n//i:
                divs.append(n//i)
    
    return divs
    
def binary_search():
    l, r = 2, 10**12+10
    
    while l<=r:
        m = (l+r)//2
        
        if (pow(m, k)-1)//(m-1)<=N//d:
            l = m+1
        else:
            r = m-1
    
    return r

N = int(input())

if N==1:
    print(2)
    exit()

if N==2:
    print(3)
    exit()
    
divs = make_divs(N)
ans = N-1

for d in divs:
    for k in range(1, 41):
        p = binary_search()
        
        if p>d and (pow(p, k)-1)//(p-1)==N//d:
            ans = min(ans, p)

print(ans)
0