結果

問題 No.1312 Snake Eyes
ユーザー 👑 H20H20
提出日時 2020-12-10 10:57:12
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 999 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 81,712 KB
実行使用メモリ 76,068 KB
最終ジャッジ日時 2023-10-19 22:46:39
合計ジャッジ時間 13,609 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
70,024 KB
testcase_01 AC 53 ms
70,024 KB
testcase_02 AC 67 ms
75,268 KB
testcase_03 AC 39 ms
53,556 KB
testcase_04 AC 39 ms
53,556 KB
testcase_05 AC 55 ms
70,024 KB
testcase_06 AC 54 ms
70,024 KB
testcase_07 AC 54 ms
70,024 KB
testcase_08 AC 68 ms
75,128 KB
testcase_09 AC 54 ms
70,024 KB
testcase_10 AC 67 ms
75,268 KB
testcase_11 AC 53 ms
70,024 KB
testcase_12 AC 67 ms
75,264 KB
testcase_13 AC 67 ms
75,264 KB
testcase_14 AC 94 ms
75,220 KB
testcase_15 AC 67 ms
75,268 KB
testcase_16 AC 67 ms
75,264 KB
testcase_17 AC 81 ms
75,188 KB
testcase_18 AC 66 ms
75,276 KB
testcase_19 AC 66 ms
75,264 KB
testcase_20 AC 67 ms
75,264 KB
testcase_21 AC 75 ms
75,296 KB
testcase_22 AC 53 ms
70,024 KB
testcase_23 AC 154 ms
75,652 KB
testcase_24 AC 83 ms
75,340 KB
testcase_25 AC 67 ms
75,272 KB
testcase_26 AC 73 ms
75,124 KB
testcase_27 AC 67 ms
75,132 KB
testcase_28 AC 94 ms
75,360 KB
testcase_29 AC 66 ms
75,264 KB
testcase_30 AC 124 ms
75,264 KB
testcase_31 AC 103 ms
75,360 KB
testcase_32 AC 81 ms
75,180 KB
testcase_33 AC 53 ms
70,024 KB
testcase_34 AC 91 ms
75,196 KB
testcase_35 AC 69 ms
75,132 KB
testcase_36 AC 105 ms
75,220 KB
testcase_37 AC 94 ms
75,376 KB
testcase_38 AC 184 ms
75,620 KB
testcase_39 AC 90 ms
75,460 KB
testcase_40 AC 70 ms
75,268 KB
testcase_41 AC 148 ms
75,612 KB
testcase_42 AC 68 ms
75,368 KB
testcase_43 AC 81 ms
75,312 KB
testcase_44 AC 83 ms
75,436 KB
testcase_45 AC 67 ms
75,264 KB
testcase_46 AC 82 ms
75,436 KB
testcase_47 AC 54 ms
70,240 KB
testcase_48 AC 508 ms
75,956 KB
testcase_49 AC 197 ms
75,920 KB
testcase_50 AC 115 ms
75,480 KB
testcase_51 AC 113 ms
75,476 KB
testcase_52 AC 97 ms
75,440 KB
testcase_53 AC 151 ms
75,660 KB
testcase_54 AC 118 ms
75,488 KB
testcase_55 AC 88 ms
75,436 KB
testcase_56 AC 350 ms
75,872 KB
testcase_57 AC 91 ms
75,436 KB
testcase_58 AC 163 ms
75,804 KB
testcase_59 AC 191 ms
75,696 KB
testcase_60 AC 76 ms
75,368 KB
testcase_61 AC 163 ms
75,776 KB
testcase_62 AC 157 ms
75,816 KB
testcase_63 AC 84 ms
75,452 KB
testcase_64 AC 104 ms
75,332 KB
testcase_65 AC 73 ms
75,388 KB
testcase_66 AC 148 ms
75,656 KB
testcase_67 AC 94 ms
75,220 KB
testcase_68 AC 69 ms
75,364 KB
testcase_69 AC 98 ms
75,600 KB
testcase_70 AC 235 ms
76,068 KB
testcase_71 AC 157 ms
75,776 KB
testcase_72 AC 151 ms
75,644 KB
testcase_73 AC 84 ms
75,456 KB
testcase_74 AC 76 ms
75,292 KB
testcase_75 AC 80 ms
75,312 KB
testcase_76 TLE -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#約数列挙
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i < n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors+upper_divisors[::-1]

#めぐる式二部探索
#参考サイト:https://aotamasaki.hatenablog.com/entry/meguru_bisect

def is_ok(arg,tar,n):
    return (arg**n-1)//(arg-1) <= tar

def meguru_bisect(ng, ok, tar, n):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid,tar,n):
            ok = mid
        else:
            ng = mid
    return ok

N = int(input())
L=make_divisors(N)
ans = N-1
if N == 1:
    print(2)
    exit()
if N == 2:
    print(3)
    exit()


for l in L:
    for i in range(2,41):
        temp = meguru_bisect(10**12+1, 2 ,l ,i)
        if temp>N//l and (temp**i-1)//(temp-1)==l:
            ans = min(temp,ans)
        if temp == 1:
            break

print(ans)
0