結果

問題 No.550 夏休みの思い出(1)
ユーザー mkawa2mkawa2
提出日時 2021-11-12 16:04:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 1,436 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-05-03 22:29:57
合計ジャッジ時間 9,205 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = 18446744073709551615
inf = 4294967295
md = 10**9+7
# md = 998244353

def factors(a):
    if a <= 0: return [0]
    dd0, dd1 = [], []
    for d in range(1, min(round(a**0.5), 10**6)+1):
        if a%d: continue
        dd0.append(d)
    return dd0

def PolDiv(aa, v):
    res = [aa[-1]]*(len(aa)-1)
    for i in range(len(aa)-3, -1, -1):
        res[i] = res[i+1]*v+aa[i+1]
    rem = res[0]*v+aa[0]
    return res, rem

a, b, c = LI()
ans = []
if c == 0:
    a, b, c = 1, a, b
    ans.append(0)
else:
    ff = factors(abs(c))
    ff += [-f for f in ff]
    for f in ff:
        if f**3+a*f**2+b*f+c == 0:
            ans.append(f)
            break

    abc, _ = PolDiv([c, b, a, 1], ans[0])
    c, b, a = abc

# print(ans, a, b, c)
# print(b**2-4*a*c)
d = round((b**2-4*a*c)**0.5)
ans.append((-b+d)//a//2)
ans.append((-b-d)//a//2)
ans.sort()
print(*ans)
0