結果
| 問題 |
No.550 夏休みの思い出(1)
|
| ユーザー |
tsutaj
|
| 提出日時 | 2019-03-28 07:26:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 2,000 ms |
| コード長 | 1,953 bytes |
| コンパイル時間 | 974 ms |
| コンパイル使用メモリ | 105,892 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 04:44:45 |
| 合計ジャッジ時間 | 2,748 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 55 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:84:31: warning: 'Z' may be used uninitialized [-Wmaybe-uninitialized]
84 | vector<int> ans = {X, Y, Z};
| ^
main.cpp:50:15: note: 'Z' was declared here
50 | int X, Y, Z;
| ^
ソースコード
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
signed main() {
int A, B, C;
cin >> A >> B >> C;
int lb = -1000 * 1000, ub = -lb;
int X, Y, Z;
for(X=lb; X<=ub; X++) {
__int128_t ea = (__int128_t)X*X*X;
__int128_t eb = (__int128_t)A*X*X;
__int128_t ec = (__int128_t)B*X+C;
if(ea + eb + ec == 0) {
break;
}
}
if(X == 0) {
// X(X-p)(X-q)
// X^2 + A*X + B = 0
C = B, B = A;
}
else {
// (X-p)(X-q)(X-r)
// 多項式を X-r で割る
C = -C/X, B = A+X;
}
long double D = B*B - 4*C;
long double S = (-B + sqrt(D)) / 2.0;
for(Y=S-2; Y<=S+2; Y++) {
Z = -B-Y;
const int NINE = 1000000000;
if(abs(Y) > NINE) continue;
if(abs(Z) > NINE) continue;
if(Y*Z != C) continue;
if(Y+Z != -B) continue;
break;
}
vector<int> ans = {X, Y, Z};
sort(ans.begin(), ans.end());
printf("%lld %lld %lld\n", ans[0], ans[1], ans[2]);
return 0;
}
tsutaj