結果

問題 No.1312 Snake Eyes
ユーザー rlangevinrlangevin
提出日時 2023-04-17 19:32:13
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 740 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 82,232 KB
実行使用メモリ 89,176 KB
最終ジャッジ日時 2024-04-20 22:21:38
合計ジャッジ時間 7,791 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
60,308 KB
testcase_01 AC 39 ms
54,156 KB
testcase_02 AC 40 ms
53,320 KB
testcase_03 AC 38 ms
52,992 KB
testcase_04 AC 38 ms
52,888 KB
testcase_05 AC 38 ms
53,072 KB
testcase_06 AC 38 ms
52,948 KB
testcase_07 AC 41 ms
52,648 KB
testcase_08 AC 39 ms
52,544 KB
testcase_09 AC 39 ms
52,212 KB
testcase_10 AC 39 ms
53,424 KB
testcase_11 AC 39 ms
52,744 KB
testcase_12 AC 39 ms
52,988 KB
testcase_13 AC 39 ms
52,072 KB
testcase_14 AC 39 ms
53,956 KB
testcase_15 AC 39 ms
53,872 KB
testcase_16 AC 39 ms
53,308 KB
testcase_17 AC 38 ms
52,948 KB
testcase_18 AC 40 ms
53,436 KB
testcase_19 AC 39 ms
52,732 KB
testcase_20 AC 40 ms
53,932 KB
testcase_21 AC 40 ms
53,876 KB
testcase_22 AC 39 ms
53,560 KB
testcase_23 AC 61 ms
68,756 KB
testcase_24 AC 60 ms
69,120 KB
testcase_25 AC 57 ms
68,160 KB
testcase_26 AC 57 ms
65,760 KB
testcase_27 AC 60 ms
66,928 KB
testcase_28 AC 60 ms
68,044 KB
testcase_29 AC 70 ms
74,648 KB
testcase_30 AC 63 ms
70,080 KB
testcase_31 AC 62 ms
70,264 KB
testcase_32 AC 63 ms
70,280 KB
testcase_33 AC 58 ms
66,516 KB
testcase_34 AC 62 ms
69,400 KB
testcase_35 AC 62 ms
69,408 KB
testcase_36 AC 64 ms
69,304 KB
testcase_37 AC 64 ms
70,612 KB
testcase_38 AC 100 ms
76,140 KB
testcase_39 AC 137 ms
75,892 KB
testcase_40 AC 138 ms
76,276 KB
testcase_41 AC 134 ms
76,412 KB
testcase_42 AC 109 ms
75,876 KB
testcase_43 AC 140 ms
76,172 KB
testcase_44 AC 105 ms
76,052 KB
testcase_45 AC 123 ms
76,284 KB
testcase_46 AC 119 ms
75,892 KB
testcase_47 AC 108 ms
76,016 KB
testcase_48 TLE -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
if N == 1:
    print(2)
    exit()
if N == 2:
    print(3)
    exit()

inf = 10 ** 18
def f(p, d):
    if p >= 10 ** 9 and d >= 3:
        return inf
    if p >= 10 ** 6 and d >= 4:
        return inf
    if p >= 10 ** 4 and d >= 5:
        return inf
    return (p ** d - 1) // (p - 1)

ans = N - 1
for d in range(2, 45):
    for v in range(1, 10**18):
        if v * f(v + 1, d) > N:
            break
        yes = v + 1
        no = N + 1
        if no <= yes:
            break
        while no - yes != 1:
            mid = (yes + no)//2
            if v * f(mid, d) <= N:
                yes = mid
            else:
                no  = mid
        if v * f(yes, d) == N:
            ans = min(ans, yes)

print(ans)
0