結果

問題 No.1312 Snake Eyes
ユーザー rlangevinrlangevin
提出日時 2023-04-17 19:27:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 729 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 76,672 KB
最終ジャッジ日時 2024-04-20 22:18:40
合計ジャッジ時間 37,018 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
52,096 KB
testcase_01 AC 45 ms
52,096 KB
testcase_02 AC 44 ms
52,068 KB
testcase_03 AC 42 ms
51,584 KB
testcase_04 AC 41 ms
51,968 KB
testcase_05 AC 39 ms
52,096 KB
testcase_06 AC 42 ms
51,584 KB
testcase_07 AC 42 ms
52,352 KB
testcase_08 AC 41 ms
51,712 KB
testcase_09 AC 42 ms
52,480 KB
testcase_10 AC 41 ms
51,840 KB
testcase_11 AC 44 ms
52,224 KB
testcase_12 AC 46 ms
51,968 KB
testcase_13 AC 46 ms
52,096 KB
testcase_14 AC 46 ms
52,224 KB
testcase_15 AC 45 ms
52,568 KB
testcase_16 AC 45 ms
52,480 KB
testcase_17 AC 44 ms
52,224 KB
testcase_18 AC 45 ms
52,480 KB
testcase_19 AC 45 ms
52,480 KB
testcase_20 AC 45 ms
52,480 KB
testcase_21 AC 45 ms
52,480 KB
testcase_22 AC 45 ms
52,352 KB
testcase_23 AC 70 ms
67,712 KB
testcase_24 AC 69 ms
66,432 KB
testcase_25 AC 63 ms
65,536 KB
testcase_26 AC 61 ms
65,024 KB
testcase_27 AC 65 ms
66,560 KB
testcase_28 AC 66 ms
66,816 KB
testcase_29 AC 74 ms
72,832 KB
testcase_30 AC 67 ms
68,864 KB
testcase_31 AC 66 ms
68,352 KB
testcase_32 AC 67 ms
68,992 KB
testcase_33 AC 60 ms
66,048 KB
testcase_34 AC 68 ms
68,352 KB
testcase_35 AC 67 ms
68,096 KB
testcase_36 AC 72 ms
68,992 KB
testcase_37 AC 68 ms
68,736 KB
testcase_38 AC 125 ms
76,032 KB
testcase_39 AC 153 ms
75,796 KB
testcase_40 AC 151 ms
75,904 KB
testcase_41 AC 141 ms
76,160 KB
testcase_42 AC 110 ms
76,288 KB
testcase_43 AC 132 ms
75,632 KB
testcase_44 AC 119 ms
76,032 KB
testcase_45 AC 137 ms
76,232 KB
testcase_46 AC 129 ms
75,648 KB
testcase_47 AC 116 ms
75,940 KB
testcase_48 AC 1,233 ms
76,412 KB
testcase_49 AC 1,077 ms
76,352 KB
testcase_50 AC 856 ms
76,288 KB
testcase_51 AC 484 ms
76,160 KB
testcase_52 WA -
testcase_53 AC 984 ms
76,544 KB
testcase_54 AC 1,168 ms
75,904 KB
testcase_55 WA -
testcase_56 AC 807 ms
76,160 KB
testcase_57 WA -
testcase_58 AC 1,046 ms
76,032 KB
testcase_59 AC 453 ms
75,976 KB
testcase_60 WA -
testcase_61 AC 1,341 ms
76,032 KB
testcase_62 AC 586 ms
76,288 KB
testcase_63 AC 99 ms
75,784 KB
testcase_64 AC 145 ms
76,112 KB
testcase_65 AC 239 ms
76,160 KB
testcase_66 AC 61 ms
65,024 KB
testcase_67 AC 41 ms
52,736 KB
testcase_68 AC 152 ms
76,032 KB
testcase_69 AC 69 ms
70,656 KB
testcase_70 AC 1,035 ms
76,288 KB
testcase_71 AC 685 ms
76,160 KB
testcase_72 AC 143 ms
75,904 KB
testcase_73 AC 89 ms
75,520 KB
testcase_74 AC 62 ms
65,536 KB
testcase_75 AC 81 ms
74,400 KB
testcase_76 AC 1,319 ms
76,160 KB
testcase_77 AC 1,355 ms
76,160 KB
testcase_78 AC 1,332 ms
76,032 KB
testcase_79 AC 1,007 ms
76,032 KB
testcase_80 AC 1,327 ms
76,032 KB
testcase_81 AC 1,348 ms
76,416 KB
testcase_82 AC 1,347 ms
76,096 KB
testcase_83 AC 1,334 ms
76,288 KB
testcase_84 AC 1,360 ms
76,032 KB
testcase_85 AC 1,185 ms
76,064 KB
testcase_86 AC 1,154 ms
75,904 KB
testcase_87 WA -
権限があれば一括ダウンロードができます

ソースコード

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:
        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