結果

問題 No.550 夏休みの思い出(1)
ユーザー realDivineJKrealDivineJK
提出日時 2020-05-26 16:19:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 1,670 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-21 04:21:04
合計ジャッジ時間 2,932 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,880 KB
testcase_01 AC 30 ms
11,008 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 29 ms
11,008 KB
testcase_04 AC 27 ms
11,008 KB
testcase_05 AC 30 ms
11,008 KB
testcase_06 AC 28 ms
11,008 KB
testcase_07 AC 28 ms
11,008 KB
testcase_08 AC 28 ms
11,008 KB
testcase_09 AC 27 ms
10,880 KB
testcase_10 AC 28 ms
11,008 KB
testcase_11 AC 27 ms
11,008 KB
testcase_12 AC 27 ms
11,008 KB
testcase_13 AC 27 ms
11,008 KB
testcase_14 AC 28 ms
10,880 KB
testcase_15 AC 28 ms
11,008 KB
testcase_16 AC 30 ms
10,880 KB
testcase_17 AC 28 ms
11,008 KB
testcase_18 AC 28 ms
10,880 KB
testcase_19 AC 28 ms
11,008 KB
testcase_20 AC 27 ms
11,008 KB
testcase_21 AC 27 ms
11,008 KB
testcase_22 AC 26 ms
10,880 KB
testcase_23 AC 28 ms
11,008 KB
testcase_24 AC 26 ms
11,008 KB
testcase_25 AC 26 ms
10,880 KB
testcase_26 AC 27 ms
11,008 KB
testcase_27 AC 28 ms
11,008 KB
testcase_28 AC 28 ms
11,008 KB
testcase_29 AC 29 ms
10,880 KB
testcase_30 AC 28 ms
10,880 KB
testcase_31 AC 28 ms
11,008 KB
testcase_32 AC 28 ms
11,008 KB
testcase_33 AC 28 ms
11,008 KB
testcase_34 AC 30 ms
11,008 KB
testcase_35 AC 30 ms
11,008 KB
testcase_36 AC 28 ms
11,008 KB
testcase_37 AC 28 ms
11,008 KB
testcase_38 AC 28 ms
11,008 KB
testcase_39 AC 27 ms
10,880 KB
testcase_40 AC 28 ms
11,008 KB
testcase_41 AC 28 ms
10,880 KB
testcase_42 AC 28 ms
10,880 KB
testcase_43 AC 28 ms
11,008 KB
testcase_44 AC 27 ms
11,008 KB
testcase_45 AC 27 ms
11,008 KB
testcase_46 AC 28 ms
11,008 KB
testcase_47 AC 28 ms
11,008 KB
testcase_48 AC 27 ms
11,008 KB
testcase_49 AC 27 ms
11,008 KB
testcase_50 AC 27 ms
11,008 KB
testcase_51 AC 27 ms
11,008 KB
testcase_52 AC 28 ms
10,880 KB
testcase_53 AC 28 ms
10,880 KB
testcase_54 AC 28 ms
11,008 KB
testcase_55 AC 27 ms
11,008 KB
testcase_56 AC 28 ms
11,008 KB
testcase_57 AC 29 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

a, b, c = map(int, input().split())
xmin, xmax = -int(1e9), int(1e9)
def f(x):
    return x**3 + a*x**2 + b*x + c
def dfdx(x):
    return 3*x**2 + 2*a*x + b
    
x0, x1 = 0, 0
if a % 3 == 0:
    x0 = -(a // 3)
    x1 = -(a // 3)
else:
    x0 = -(a // 3)
    x1 = -(a // 3) + 1
l, r = xmin, x0
d = (l + r) // 2
L, R = x1, xmax
D = (L + R) // 2
for i in range(100):
    if dfdx(d) >= 0:
        l = d
        d = (l + r) // 2
    else:
        r = d
        d = (l + r) // 2
    if dfdx(D) <= 0:
        L = D
        D = (L + R) // 2
    else:
        R = D
        D = (L + R) // 2
l1, r1 = xmin, d
d1 = (l1 + r1) // 2
l2, r2 = d+(dfdx(d)!=0), D
d2 = (l2 + r2) // 2
l3, r3 = D+(dfdx(D)!=0), xmax
d3 = (l3 + r3) // 2
for i in range(100):
    if f(d1) < 0:
        l1 = d1 + 1
        d1 = (l1 + r1) // 2
    else:
        if f(d1) == 0:
            break
        r1 = d1
        d1 = (l1 + r1) // 2
for i in range(100):
    if f(d2) >= 0:
        if f(d2) == 0:
            break
        l2 = d2
        d2 = (l2 + r2) // 2
    else:
        r2 = d2
        d2 = (l2 + r2) // 2
for i in range(100):
    if f(d3) < 0:
        l3 = d3 + 1
        d3 = (l3 + r3) // 2
    else:
        if f(d3) == 0:
            break
        r3 = d3
        d3 = (l3 + r3) // 2
vec = [-1, 0, 1]
if f(d1) == 0 and f(d2) == 0 and f(d3) == 0 and d1 < d2 < d3:
    print(d1, d2, d3)
else:
    d = [d1, d2, d3]
    for i in range(27):
        tmp = i
        x = [0, 0, 0]
        for j in range(3):
            x[j] = d[j] + vec[tmp%3]
            tmp //= 3
        if f(x[0]) == 0 and f(x[1]) == 0 and f(x[2]) == 0 and x[0] < x[1] < x[2]:
            print(x[0], x[1], x[2])
            break
0