結果

問題 No.1042 愚直大学
ユーザー ThetaTheta
提出日時 2022-10-07 14:33:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 892 bytes
コンパイル時間 540 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 12,964 KB
最終ジャッジ日時 2023-09-02 15:05:15
合計ジャッジ時間 5,140 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
12,356 KB
testcase_01 AC 16 ms
7,912 KB
testcase_02 AC 17 ms
7,880 KB
testcase_03 AC 17 ms
7,880 KB
testcase_04 AC 16 ms
7,976 KB
testcase_05 AC 17 ms
7,924 KB
testcase_06 AC 17 ms
7,904 KB
testcase_07 AC 16 ms
7,932 KB
testcase_08 AC 16 ms
7,896 KB
testcase_09 AC 17 ms
8,012 KB
testcase_10 AC 17 ms
8,012 KB
testcase_11 AC 16 ms
7,892 KB
testcase_12 AC 17 ms
8,016 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import log2, log


class DiffSolveTime:
    def __init__(self, p: int, q: int):
        self.__p = p
        self.__q = q

    def diff_solve_time(self, n: int | float) -> float:
        return n ** 2 - self.__p - self.__q * n * log2(n)

    def diff_solve_time_derived(self, n: int | float) -> float:
        return n * 2 - self.__q * log2(n) - self.__q / log(2)

    def diff2_solve_time_derived(self, n: int | float) -> float:
        return 2 - self.__q / (n * log(2))

    def get_inflection(self) -> float:
        return self.__q / (2*log(2))


def main():
    P, Q = map(int, input().split())

    solver = DiffSolveTime(P, Q)
    N = 1e2
    while solver.diff_solve_time(N) < 0:
        N *= 10

    while abs(solver.diff_solve_time(N)) > 1e-6:
        N -= (solver.diff_solve_time(N)/solver.diff_solve_time_derived(N))
    print(N)


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