結果

問題 No.550 夏休みの思い出(1)
ユーザー 0x19f
提出日時 2017-07-29 00:49:12
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 610 bytes
コンパイル時間 881 ms
コンパイル使用メモリ 64,708 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-10 11:17:48
合計ジャッジ時間 2,297 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 49 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll A, B, C;

ll f(ll x) {
  return x * x * x + A * x * x + B * x + C;
}

int main(void) {
  cin >> A >> B >> C;

  ll ans[3];
  REP(i, 0, 1000001) {
    if(f(i) == 0) ans[0] = i;
    if(f(-i) == 0) ans[0] = -i;
  }
  ll p = A + ans[0];
  ll q = ans[0] != 0 ? -C / ans[0] : B;
  ans[1] = (-p + sqrt(p * p - 4 * q)) / 2;
  ans[2] = (-p - sqrt(p * p - 4 * q)) / 2;
  sort(ans, ans + 3);

  cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
}
0