結果

問題 No.1312 Snake Eyes
ユーザー 👑 H20H20
提出日時 2020-12-09 23:07:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 915 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 81,452 KB
実行使用メモリ 79,916 KB
最終ジャッジ日時 2023-10-19 09:26:44
合計ジャッジ時間 10,344 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
57,628 KB
testcase_01 AC 40 ms
53,280 KB
testcase_02 AC 40 ms
53,280 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 39 ms
53,280 KB
testcase_06 AC 39 ms
53,280 KB
testcase_07 AC 42 ms
53,280 KB
testcase_08 AC 39 ms
53,280 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 39 ms
53,280 KB
testcase_12 AC 40 ms
53,280 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 38 ms
53,284 KB
testcase_16 AC 39 ms
53,284 KB
testcase_17 AC 38 ms
53,284 KB
testcase_18 AC 39 ms
53,284 KB
testcase_19 AC 40 ms
53,284 KB
testcase_20 AC 41 ms
55,332 KB
testcase_21 AC 44 ms
61,364 KB
testcase_22 AC 39 ms
53,284 KB
testcase_23 AC 71 ms
74,740 KB
testcase_24 AC 53 ms
65,584 KB
testcase_25 AC 46 ms
63,472 KB
testcase_26 AC 50 ms
65,520 KB
testcase_27 AC 47 ms
63,472 KB
testcase_28 AC 55 ms
71,744 KB
testcase_29 AC 47 ms
63,472 KB
testcase_30 AC 65 ms
74,724 KB
testcase_31 AC 63 ms
74,724 KB
testcase_32 AC 51 ms
67,632 KB
testcase_33 AC 42 ms
55,332 KB
testcase_34 AC 55 ms
71,744 KB
testcase_35 AC 47 ms
63,536 KB
testcase_36 AC 61 ms
74,724 KB
testcase_37 AC 54 ms
71,732 KB
testcase_38 AC 89 ms
74,896 KB
testcase_39 AC 65 ms
75,000 KB
testcase_40 AC 52 ms
67,868 KB
testcase_41 AC 89 ms
75,020 KB
testcase_42 AC 54 ms
65,732 KB
testcase_43 AC 65 ms
74,996 KB
testcase_44 AC 56 ms
71,876 KB
testcase_45 AC 52 ms
65,672 KB
testcase_46 AC 68 ms
75,004 KB
testcase_47 AC 46 ms
61,568 KB
testcase_48 AC 280 ms
75,348 KB
testcase_49 AC 126 ms
75,128 KB
testcase_50 AC 87 ms
75,028 KB
testcase_51 AC 81 ms
75,012 KB
testcase_52 AC 79 ms
75,004 KB
testcase_53 AC 102 ms
75,112 KB
testcase_54 AC 90 ms
75,024 KB
testcase_55 AC 70 ms
74,992 KB
testcase_56 AC 195 ms
75,368 KB
testcase_57 AC 73 ms
74,992 KB
testcase_58 AC 110 ms
75,120 KB
testcase_59 AC 114 ms
75,120 KB
testcase_60 AC 61 ms
69,916 KB
testcase_61 AC 112 ms
75,120 KB
testcase_62 AC 104 ms
75,116 KB
testcase_63 AC 55 ms
71,876 KB
testcase_64 AC 74 ms
75,008 KB
testcase_65 AC 55 ms
67,868 KB
testcase_66 AC 67 ms
74,724 KB
testcase_67 AC 50 ms
63,536 KB
testcase_68 AC 55 ms
67,920 KB
testcase_69 AC 56 ms
71,876 KB
testcase_70 AC 145 ms
75,308 KB
testcase_71 AC 103 ms
75,200 KB
testcase_72 AC 88 ms
75,036 KB
testcase_73 AC 52 ms
69,824 KB
testcase_74 AC 47 ms
65,520 KB
testcase_75 AC 52 ms
69,824 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 and (temp**i)//(temp-1)==l:
            ans = min(temp,ans)

print(ans)
0