結果

問題 No.1312 Snake Eyes
ユーザー 👑 H20H20
提出日時 2020-12-09 23:09:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 944 bytes
コンパイル時間 951 ms
コンパイル使用メモリ 81,384 KB
実行使用メモリ 80,020 KB
最終ジャッジ日時 2023-10-19 09:30:55
合計ジャッジ時間 10,603 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,628 KB
testcase_01 AC 39 ms
53,472 KB
testcase_02 AC 38 ms
53,472 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 38 ms
53,472 KB
testcase_06 AC 39 ms
53,472 KB
testcase_07 AC 38 ms
53,472 KB
testcase_08 AC 39 ms
53,472 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 39 ms
53,472 KB
testcase_12 AC 40 ms
53,472 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 39 ms
53,472 KB
testcase_16 AC 40 ms
53,472 KB
testcase_17 AC 39 ms
53,472 KB
testcase_18 AC 39 ms
53,472 KB
testcase_19 AC 39 ms
53,472 KB
testcase_20 AC 39 ms
53,472 KB
testcase_21 AC 39 ms
53,472 KB
testcase_22 AC 38 ms
53,472 KB
testcase_23 AC 55 ms
67,788 KB
testcase_24 AC 45 ms
61,556 KB
testcase_25 AC 40 ms
53,472 KB
testcase_26 AC 40 ms
53,472 KB
testcase_27 AC 40 ms
53,472 KB
testcase_28 AC 48 ms
61,624 KB
testcase_29 AC 41 ms
53,472 KB
testcase_30 AC 52 ms
65,736 KB
testcase_31 AC 51 ms
65,736 KB
testcase_32 AC 44 ms
61,556 KB
testcase_33 AC 39 ms
53,472 KB
testcase_34 AC 48 ms
63,672 KB
testcase_35 AC 39 ms
53,472 KB
testcase_36 AC 49 ms
63,672 KB
testcase_37 AC 49 ms
63,684 KB
testcase_38 AC 74 ms
75,144 KB
testcase_39 AC 55 ms
72,032 KB
testcase_40 AC 49 ms
63,836 KB
testcase_41 AC 73 ms
75,048 KB
testcase_42 AC 46 ms
61,788 KB
testcase_43 AC 53 ms
67,936 KB
testcase_44 AC 53 ms
67,940 KB
testcase_45 AC 50 ms
63,840 KB
testcase_46 AC 54 ms
67,936 KB
testcase_47 AC 45 ms
61,296 KB
testcase_48 AC 204 ms
75,376 KB
testcase_49 AC 111 ms
75,136 KB
testcase_50 AC 80 ms
75,040 KB
testcase_51 AC 76 ms
75,044 KB
testcase_52 AC 80 ms
75,164 KB
testcase_53 AC 98 ms
75,264 KB
testcase_54 AC 81 ms
75,040 KB
testcase_55 AC 71 ms
75,160 KB
testcase_56 AC 145 ms
75,356 KB
testcase_57 AC 73 ms
75,160 KB
testcase_58 AC 96 ms
75,124 KB
testcase_59 AC 95 ms
75,124 KB
testcase_60 AC 61 ms
70,140 KB
testcase_61 AC 99 ms
75,124 KB
testcase_62 AC 88 ms
75,124 KB
testcase_63 AC 54 ms
65,896 KB
testcase_64 AC 58 ms
73,116 KB
testcase_65 AC 51 ms
63,836 KB
testcase_66 AC 52 ms
65,756 KB
testcase_67 AC 39 ms
53,492 KB
testcase_68 AC 49 ms
63,836 KB
testcase_69 AC 50 ms
63,840 KB
testcase_70 AC 118 ms
75,132 KB
testcase_71 AC 89 ms
75,064 KB
testcase_72 AC 74 ms
75,152 KB
testcase_73 AC 54 ms
65,892 KB
testcase_74 AC 41 ms
55,540 KB
testcase_75 AC 48 ms
63,836 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 #

N = int(input())

#約数の後半列挙
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 upper_divisors[::-1]

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

def is_ok(arg,tar,n):
    # 整数を買えればTrueを返す
    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

L=make_divisors(N)
ans = N-1

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

print(ans)
0