結果

問題 No.1042 愚直大学
ユーザー zalgo3zalgo3
提出日時 2020-05-01 23:12:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 273 ms / 2,000 ms
コード長 499 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 10,684 KB
実行使用メモリ 56,644 KB
最終ジャッジ日時 2023-08-26 15:47:11
合計ジャッジ時間 8,827 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 261 ms
56,392 KB
testcase_01 AC 266 ms
56,236 KB
testcase_02 AC 259 ms
56,208 KB
testcase_03 AC 267 ms
56,264 KB
testcase_04 AC 265 ms
56,644 KB
testcase_05 AC 261 ms
56,540 KB
testcase_06 AC 268 ms
56,528 KB
testcase_07 AC 269 ms
56,376 KB
testcase_08 AC 263 ms
56,280 KB
testcase_09 AC 268 ms
56,332 KB
testcase_10 AC 273 ms
56,284 KB
testcase_11 AC 264 ms
56,212 KB
testcase_12 AC 258 ms
56,188 KB
testcase_13 AC 264 ms
56,468 KB
testcase_14 AC 272 ms
56,544 KB
testcase_15 AC 264 ms
56,408 KB
testcase_16 AC 268 ms
56,464 KB
testcase_17 AC 270 ms
56,448 KB
testcase_18 AC 265 ms
56,392 KB
testcase_19 AC 266 ms
56,264 KB
testcase_20 AC 267 ms
56,544 KB
testcase_21 AC 266 ms
56,468 KB
testcase_22 AC 259 ms
56,336 KB
testcase_23 AC 267 ms
56,036 KB
testcase_24 AC 265 ms
56,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
from scipy.optimize import newton

p, q = map(int, input().split())

def f(x):
    return x * x - q * x * math.log2(x) - p

def fprime(x):
    return 2 * x - q * math.log2(x) - q / math.log(2)

#def newton(x_0, eps):
#    x = x_0
#    while True:
#        x_prev = x
#        x = x_prev - f(x) / fprime(x)
#        if abs(x - x_prev) < eps:
#            break
#    return x

x0 = 1.0
while True:
    x0 *= 10
    if f(x0) > 0:
        break
print(newton(f, x0, fprime=fprime, tol=1e-5))
0