結果

問題 No.1312 Snake Eyes
ユーザー roarisroaris
提出日時 2020-12-09 00:47:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,880 ms / 2,000 ms
コード長 940 bytes
コンパイル時間 776 ms
コンパイル使用メモリ 81,892 KB
実行使用メモリ 76,524 KB
最終ジャッジ日時 2023-10-19 02:29:48
合計ジャッジ時間 12,317 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
66,028 KB
testcase_01 AC 61 ms
68,064 KB
testcase_02 AC 69 ms
72,220 KB
testcase_03 AC 49 ms
55,568 KB
testcase_04 AC 44 ms
55,568 KB
testcase_05 AC 58 ms
66,024 KB
testcase_06 AC 60 ms
68,072 KB
testcase_07 AC 58 ms
66,024 KB
testcase_08 AC 59 ms
68,072 KB
testcase_09 AC 59 ms
66,024 KB
testcase_10 AC 66 ms
70,152 KB
testcase_11 AC 60 ms
68,072 KB
testcase_12 AC 64 ms
70,152 KB
testcase_13 AC 67 ms
72,212 KB
testcase_14 AC 77 ms
75,592 KB
testcase_15 AC 69 ms
72,236 KB
testcase_16 AC 67 ms
72,216 KB
testcase_17 AC 75 ms
75,588 KB
testcase_18 AC 69 ms
72,236 KB
testcase_19 AC 64 ms
72,204 KB
testcase_20 AC 69 ms
72,236 KB
testcase_21 AC 75 ms
75,600 KB
testcase_22 AC 60 ms
66,032 KB
testcase_23 AC 90 ms
75,812 KB
testcase_24 AC 77 ms
75,596 KB
testcase_25 AC 68 ms
72,228 KB
testcase_26 AC 75 ms
75,588 KB
testcase_27 AC 68 ms
72,228 KB
testcase_28 AC 79 ms
75,624 KB
testcase_29 AC 68 ms
72,232 KB
testcase_30 AC 85 ms
75,632 KB
testcase_31 AC 80 ms
75,596 KB
testcase_32 AC 76 ms
75,596 KB
testcase_33 AC 61 ms
68,096 KB
testcase_34 AC 80 ms
75,624 KB
testcase_35 AC 73 ms
72,852 KB
testcase_36 AC 79 ms
75,596 KB
testcase_37 AC 79 ms
75,596 KB
testcase_38 AC 95 ms
75,904 KB
testcase_39 AC 79 ms
75,692 KB
testcase_40 AC 69 ms
72,360 KB
testcase_41 AC 89 ms
75,880 KB
testcase_42 AC 69 ms
72,360 KB
testcase_43 AC 80 ms
75,692 KB
testcase_44 AC 80 ms
75,704 KB
testcase_45 AC 69 ms
72,360 KB
testcase_46 AC 76 ms
75,684 KB
testcase_47 AC 60 ms
68,220 KB
testcase_48 AC 153 ms
76,056 KB
testcase_49 AC 114 ms
76,060 KB
testcase_50 AC 95 ms
75,856 KB
testcase_51 AC 90 ms
75,852 KB
testcase_52 AC 97 ms
75,852 KB
testcase_53 AC 107 ms
76,048 KB
testcase_54 AC 98 ms
75,844 KB
testcase_55 AC 90 ms
75,852 KB
testcase_56 AC 130 ms
76,068 KB
testcase_57 AC 91 ms
75,848 KB
testcase_58 AC 106 ms
76,052 KB
testcase_59 AC 102 ms
76,056 KB
testcase_60 AC 85 ms
75,824 KB
testcase_61 AC 109 ms
76,052 KB
testcase_62 AC 99 ms
76,044 KB
testcase_63 AC 79 ms
75,700 KB
testcase_64 AC 76 ms
75,636 KB
testcase_65 AC 69 ms
72,344 KB
testcase_66 AC 90 ms
75,816 KB
testcase_67 AC 78 ms
75,600 KB
testcase_68 AC 70 ms
72,360 KB
testcase_69 AC 79 ms
75,692 KB
testcase_70 AC 115 ms
76,056 KB
testcase_71 AC 102 ms
76,048 KB
testcase_72 AC 90 ms
75,856 KB
testcase_73 AC 78 ms
75,692 KB
testcase_74 AC 75 ms
75,588 KB
testcase_75 AC 73 ms
75,640 KB
testcase_76 AC 1,880 ms
76,524 KB
testcase_77 AC 82 ms
72,480 KB
testcase_78 AC 95 ms
75,852 KB
testcase_79 AC 96 ms
75,664 KB
testcase_80 AC 81 ms
70,424 KB
testcase_81 AC 93 ms
75,828 KB
testcase_82 AC 138 ms
76,040 KB
testcase_83 AC 151 ms
76,056 KB
testcase_84 AC 81 ms
70,436 KB
testcase_85 AC 105 ms
75,872 KB
testcase_86 AC 156 ms
76,160 KB
testcase_87 AC 80 ms
73,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def make_divs(n):
    divs = []
    i = 1
    
    while i*i<=n:
        if n%i==0:
            divs.append(i)
            
            if i!=n//i:
                divs.append(n//i)
        
        i += 1
        
    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**13
    
    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, 45):
        p = binary_search()
        
        if p>d and (pow(p, k)-1)//(p-1)==N//d:
            ans = min(ans, p)

print(ans)
0