結果

問題 No.1312 Snake Eyes
ユーザー roarisroaris
提出日時 2020-12-09 00:49:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,549 ms / 2,000 ms
コード長 925 bytes
コンパイル時間 529 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 78,420 KB
最終ジャッジ日時 2023-08-20 11:12:36
合計ジャッジ時間 16,968 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
77,612 KB
testcase_01 AC 107 ms
77,476 KB
testcase_02 AC 115 ms
77,812 KB
testcase_03 AC 96 ms
71,736 KB
testcase_04 AC 91 ms
71,580 KB
testcase_05 AC 105 ms
77,556 KB
testcase_06 AC 106 ms
77,476 KB
testcase_07 AC 105 ms
77,404 KB
testcase_08 AC 106 ms
77,656 KB
testcase_09 AC 104 ms
77,688 KB
testcase_10 AC 109 ms
77,308 KB
testcase_11 AC 107 ms
77,332 KB
testcase_12 AC 114 ms
77,512 KB
testcase_13 AC 114 ms
77,236 KB
testcase_14 AC 118 ms
77,708 KB
testcase_15 AC 114 ms
77,492 KB
testcase_16 AC 112 ms
77,688 KB
testcase_17 AC 114 ms
77,624 KB
testcase_18 AC 111 ms
77,628 KB
testcase_19 AC 109 ms
77,396 KB
testcase_20 AC 111 ms
77,360 KB
testcase_21 AC 111 ms
77,696 KB
testcase_22 AC 105 ms
77,688 KB
testcase_23 AC 128 ms
77,872 KB
testcase_24 AC 119 ms
77,532 KB
testcase_25 AC 111 ms
77,680 KB
testcase_26 AC 116 ms
77,784 KB
testcase_27 AC 114 ms
77,956 KB
testcase_28 AC 116 ms
77,856 KB
testcase_29 AC 113 ms
77,476 KB
testcase_30 AC 124 ms
77,948 KB
testcase_31 AC 120 ms
78,032 KB
testcase_32 AC 118 ms
77,420 KB
testcase_33 AC 105 ms
77,924 KB
testcase_34 AC 122 ms
77,760 KB
testcase_35 AC 111 ms
77,924 KB
testcase_36 AC 123 ms
77,860 KB
testcase_37 AC 127 ms
78,092 KB
testcase_38 AC 141 ms
78,004 KB
testcase_39 AC 120 ms
78,096 KB
testcase_40 AC 116 ms
77,660 KB
testcase_41 AC 130 ms
77,984 KB
testcase_42 AC 118 ms
78,024 KB
testcase_43 AC 122 ms
77,996 KB
testcase_44 AC 118 ms
78,088 KB
testcase_45 AC 118 ms
77,844 KB
testcase_46 AC 118 ms
77,796 KB
testcase_47 AC 108 ms
77,708 KB
testcase_48 AC 183 ms
78,208 KB
testcase_49 AC 148 ms
77,984 KB
testcase_50 AC 136 ms
77,756 KB
testcase_51 AC 126 ms
77,756 KB
testcase_52 AC 138 ms
78,056 KB
testcase_53 AC 144 ms
78,308 KB
testcase_54 AC 140 ms
77,864 KB
testcase_55 AC 128 ms
77,796 KB
testcase_56 AC 160 ms
78,316 KB
testcase_57 AC 133 ms
78,064 KB
testcase_58 AC 146 ms
78,276 KB
testcase_59 AC 141 ms
78,248 KB
testcase_60 AC 126 ms
77,972 KB
testcase_61 AC 148 ms
78,256 KB
testcase_62 AC 140 ms
78,420 KB
testcase_63 AC 114 ms
77,768 KB
testcase_64 AC 116 ms
78,072 KB
testcase_65 AC 114 ms
77,940 KB
testcase_66 AC 125 ms
78,140 KB
testcase_67 AC 116 ms
77,588 KB
testcase_68 AC 116 ms
77,728 KB
testcase_69 AC 119 ms
77,964 KB
testcase_70 AC 153 ms
78,200 KB
testcase_71 AC 137 ms
78,188 KB
testcase_72 AC 125 ms
77,828 KB
testcase_73 AC 118 ms
78,004 KB
testcase_74 AC 115 ms
77,568 KB
testcase_75 AC 115 ms
77,972 KB
testcase_76 AC 1,549 ms
78,364 KB
testcase_77 AC 123 ms
77,888 KB
testcase_78 AC 130 ms
78,052 KB
testcase_79 AC 132 ms
77,976 KB
testcase_80 AC 124 ms
77,684 KB
testcase_81 AC 132 ms
77,720 KB
testcase_82 AC 163 ms
78,364 KB
testcase_83 AC 177 ms
78,296 KB
testcase_84 AC 120 ms
77,608 KB
testcase_85 AC 138 ms
78,192 KB
testcase_86 AC 187 ms
78,232 KB
testcase_87 AC 125 ms
77,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *

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 judge(x):
    res = 0
    
    for i in range(k):
        res += pow(x, i)
        
        if res>N//d:
            return False
        
    return True
    
def binary_search():
    l, r = 2, 10**12+10
    
    while l<=r:
        m = (l+r)//2
        
        if judge(m):
            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