結果
問題 |
No.550 夏休みの思い出(1)
|
ユーザー |
![]() |
提出日時 | 2019-09-28 20:37:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 686 bytes |
コンパイル時間 | 605 ms |
コンパイル使用メモリ | 65,288 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-03 04:14:01 |
合計ジャッジ時間 | 2,020 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 52 WA * 3 |
ソースコード
#include <iostream> #include <cmath> #include <algorithm> using namespace std; typedef long long ll; const int N = 1e6; ll A, B, C; ll calc(ll x){ return x*x*x+A*x*x+B*x+C; } int main(){ cin >> A >> B >> C; int ans[3]; for(int i = -N; i <= N; i++){ if(calc(i) == 0){ ans[0] = i; break; } } ll b, c; if(ans[0] == 0){ b = A; c = B; }else{ b = A+ans[0]; c = -C/ans[0]; } ll sq = sqrt(b*b-4*c); if((sq+1)*(sq+1) == b*b-4*c) sq = sq+1; ans[1] = (-b-sq)/2; ans[2] = (-b+sq)/2; sort(ans, ans+3); cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl; }