結果
問題 |
No.550 夏休みの思い出(1)
|
ユーザー |
![]() |
提出日時 | 2019-09-28 20:35:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 643 bytes |
コンパイル時間 | 585 ms |
コンパイル使用メモリ | 60,648 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-03 04:13:56 |
合計ジャッジ時間 | 2,170 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 WA * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:30:20: warning: ‘ans[0]’ may be used uninitialized in this function [-Wmaybe-uninitialized] 30 | b = A+ans[0]; | ~~~~~^
ソースコード
#include <iostream> #include <cmath> 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 = C; }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; cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl; }