結果

問題 No.1664 Unstable f(n)
ユーザー uir0uir0
提出日時 2021-09-03 23:08:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 557 bytes
コンパイル時間 393 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 16,128 KB
最終ジャッジ日時 2024-05-09 06:42:05
合計ジャッジ時間 6,654 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
16,128 KB
testcase_01 AC 42 ms
10,624 KB
testcase_02 AC 24 ms
10,752 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 23 ms
10,624 KB
testcase_11 TLE -
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline  # "\n"を含む

def solve(n):
    # j = 0 -> i+j+k = n-1
    # j = 1 -> i+j+k = n+1
    res = 0
    for j in range(2, 1<<10):
        # i = 0 -> i+j+k = n-1
        # i = 1 -> i+j+k = n
        i = 2
        while n - i**j >= 0:
            i += 1

        if i == 2:
            break

        i -= 1
        res = max(res, i**j - i - j)

    if res <= 1:
        return n - 1
    else:
        return n - res

def main():
    n = int(input())
    res = solve(n)
    print(res)

if __name__ == "__main__":
    main()
0