問題一覧 > 通常問題

No.550 Summer Vacation Memories (1)

レベル : / AI推定難易度 : 1400 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 256 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 91
作問者 : kuuso1 / テスター : btk
お気に入りにしたユーザー ProblemId : 1282 / 自分の提出
問題文最終更新日: 2026-06-25 09:53:50
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 170 (順位表) の他の問題:

Prologue

Speaking of summer vacation, when I was a child, summer homework meant being assigned a huge amount of calculation practice in arithmetic drill books.
This is something that happened one summer day, in a year when mountains of quadratic equation exercises were assigned as summer homework.

Young kuuso: "I'm really tired of solving nothing but quadratic equations day after day."
God: "Then how about this?"
No sooner had a voice been heard from the heavens than the drill book in front of him suddenly began to shine brilliantly.
He closed his eyes against the glare, and when he timidly opened them after a while, there lay a drill book containing somewhat unfamiliar problems.

Young kuuso: "What was that light just now? Oh well."
Muttering to himself, he opened the drill book and sensed something strangely unfamiliar there.

(Question) Solve the following cubic equation.
$X^3 - 6X^2 +11X -6 = 0$

It seems that, on a divine whim, the degree had gone up by one.
He had not yet learned about cubic equations, and young kuuso fell into utter despair, not knowing what to do.
God: "This is a little bonus for you, ho ho!"
He then noticed that something like a hint had been added after the problem text.

Problem Statement

You are given a cubic equation with integer coefficients, $ X^3 + A X^2 + BX + C = 0 $.
It is guaranteed that the given cubic equation has $3$ distinct integer solutions $\alpha$, $\beta$, $\gamma$ in the range $-10^9 < \alpha , \beta , \gamma < 10^9$.
Find all of these $3$ integer solutions and output them in ascending order, from smallest to largest.

Input

$A$ $B$ $C$


All inputs are integers, and each satisfies the following constraints.
$-10^{18} < A,B,C < 10^{18}$
It is guaranteed that the equation $X^3 + AX^2 + BX + C = 0$ has 3 distinct integer solutions $\alpha , \beta , \gamma$,
and that they satisfy $-10^{9} < \alpha , \beta , \gamma < 10^{9}$.

Output

Output the 3 distinct integer solutions $\alpha , \beta , \gamma$ in ascending order, separated by single-byte spaces.
Print a newline at the end.

Sample

Sample 1
Input
0 -1 0
Output
-1 0 1


The given cubic equation is $ X^3 - X = 0 $.
By rewriting it as $ X(X-1)(X+1) = 0 $, we can see that the solutions are $ X = -1,0,1$.

Sample 2
Input
-6 11 -6
Output
1 2 3


The given cubic equation is $ X^3 - 6X^2 + 11X - 6 = 0 $.
By rewriting it as $ (X-1)(X-2)(X-3) = 0 $, we can see that the solutions are $ X = 1 , 2 , 3$.
In general, for an equation of degree $n$ with integer coefficients, if you can find $n$ distinct solutions, it is guaranteed that no others exist.

Sample 3
Input
113405 -128550416 -177999416460
Output
-114514 -810 1919


It's ascending order, so it can't be helped.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。