結果
問題 | No.550 夏休みの思い出(1) |
ユーザー |
![]() |
提出日時 | 2019-09-28 20:44:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 812 bytes |
コンパイル時間 | 490 ms |
コンパイル使用メモリ | 64,992 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-03 04:14:08 |
合計ジャッジ時間 | 1,872 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 55 |
ソースコード
#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; } double calc_d(ll y){ double x = (double)y; 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(abs(calc_d(i)) > 100000) continue; 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; }