結果

問題 No.1312 Snake Eyes
ユーザー roarisroaris
提出日時 2020-12-09 00:35:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 888 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 81,656 KB
実行使用メモリ 76,896 KB
最終ジャッジ日時 2023-10-19 02:20:48
合計ジャッジ時間 12,310 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
66,296 KB
testcase_01 AC 62 ms
68,356 KB
testcase_02 AC 72 ms
72,504 KB
testcase_03 AC 43 ms
55,612 KB
testcase_04 WA -
testcase_05 AC 60 ms
66,296 KB
testcase_06 AC 60 ms
68,344 KB
testcase_07 AC 59 ms
66,296 KB
testcase_08 AC 58 ms
70,392 KB
testcase_09 AC 56 ms
66,296 KB
testcase_10 AC 64 ms
72,472 KB
testcase_11 AC 59 ms
68,344 KB
testcase_12 AC 66 ms
72,472 KB
testcase_13 AC 67 ms
72,784 KB
testcase_14 AC 81 ms
75,892 KB
testcase_15 AC 65 ms
72,480 KB
testcase_16 AC 66 ms
72,488 KB
testcase_17 AC 75 ms
75,864 KB
testcase_18 AC 68 ms
72,500 KB
testcase_19 AC 66 ms
72,472 KB
testcase_20 AC 70 ms
73,056 KB
testcase_21 AC 80 ms
75,960 KB
testcase_22 AC 60 ms
68,352 KB
testcase_23 AC 96 ms
76,320 KB
testcase_24 AC 80 ms
75,884 KB
testcase_25 AC 73 ms
73,132 KB
testcase_26 AC 76 ms
75,872 KB
testcase_27 AC 69 ms
72,728 KB
testcase_28 AC 81 ms
75,892 KB
testcase_29 AC 75 ms
73,296 KB
testcase_30 AC 86 ms
75,904 KB
testcase_31 AC 82 ms
75,868 KB
testcase_32 AC 80 ms
75,884 KB
testcase_33 AC 61 ms
68,368 KB
testcase_34 AC 82 ms
75,892 KB
testcase_35 AC 70 ms
73,160 KB
testcase_36 AC 80 ms
75,868 KB
testcase_37 AC 82 ms
75,896 KB
testcase_38 AC 97 ms
76,168 KB
testcase_39 AC 83 ms
75,964 KB
testcase_40 AC 74 ms
74,180 KB
testcase_41 AC 92 ms
76,144 KB
testcase_42 AC 69 ms
73,212 KB
testcase_43 AC 79 ms
75,964 KB
testcase_44 AC 78 ms
75,952 KB
testcase_45 AC 78 ms
75,968 KB
testcase_46 AC 78 ms
75,952 KB
testcase_47 AC 60 ms
68,492 KB
testcase_48 AC 166 ms
76,356 KB
testcase_49 AC 120 ms
76,576 KB
testcase_50 AC 96 ms
76,132 KB
testcase_51 AC 93 ms
76,152 KB
testcase_52 AC 98 ms
76,136 KB
testcase_53 AC 111 ms
76,332 KB
testcase_54 AC 98 ms
76,232 KB
testcase_55 AC 97 ms
76,256 KB
testcase_56 AC 139 ms
76,356 KB
testcase_57 AC 94 ms
76,148 KB
testcase_58 AC 108 ms
76,356 KB
testcase_59 AC 103 ms
76,332 KB
testcase_60 AC 85 ms
76,112 KB
testcase_61 AC 115 ms
76,352 KB
testcase_62 AC 105 ms
76,332 KB
testcase_63 AC 80 ms
75,976 KB
testcase_64 AC 84 ms
75,928 KB
testcase_65 AC 70 ms
72,644 KB
testcase_66 AC 96 ms
76,128 KB
testcase_67 AC 82 ms
75,900 KB
testcase_68 AC 86 ms
76,008 KB
testcase_69 AC 80 ms
75,976 KB
testcase_70 AC 125 ms
76,584 KB
testcase_71 AC 105 ms
76,344 KB
testcase_72 AC 90 ms
76,136 KB
testcase_73 AC 82 ms
75,980 KB
testcase_74 AC 80 ms
75,884 KB
testcase_75 AC 79 ms
75,928 KB
testcase_76 TLE -
testcase_77 AC 83 ms
72,768 KB
testcase_78 AC 95 ms
76,116 KB
testcase_79 AC 92 ms
76,084 KB
testcase_80 AC 79 ms
70,708 KB
testcase_81 AC 100 ms
76,328 KB
testcase_82 AC 142 ms
76,288 KB
testcase_83 AC 162 ms
76,356 KB
testcase_84 AC 77 ms
70,700 KB
testcase_85 AC 104 ms
76,256 KB
testcase_86 AC 176 ms
76,484 KB
testcase_87 AC 98 ms
76,216 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**18
    
    while l<=r:
        m = (l+r)//2
        
        if judge(m):
            l = m+1
        else:
            r = m-1
    
    return r

N = int(input())

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

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

print(ans)
0