結果
| 問題 |
No.550 夏休みの思い出(1)
|
| コンテスト | |
| ユーザー |
kotamanegi
|
| 提出日時 | 2017-07-28 23:43:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 1,735 bytes |
| コンパイル時間 | 881 ms |
| コンパイル使用メモリ | 102,740 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-11 05:32:37 |
| 合計ジャッジ時間 | 2,637 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 55 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include<fstream>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define f(n) for(int i=0;i<n;++i)
#define REP(i,n) for(long long i = 0;i < n;++i)
#define double long long
double a, b, c;
double calc_f(double x) {
double ans = x;
ans += a;
ans *= x;
ans += b;
ans *= x;
ans += c;
return ans;
}
double calc_fd(double x) {
double ans = 3 * x;
ans += 2 * a;
ans *= x;
ans += b;
return ans;
}
int main() {
#define int long long
cin >> a >> b >> c;
double n = 0;
int cnter = 0;
failed:;
for (int i = 0;i < 50000;++i) {
n = n - (calc_f(n) / calc_fd(n));
}
//nは解の一つ
vector<long long> ans;
for (int i = 0;i >= 0;++i) {
long long nya = n;
if (i % 2 == 0) nya += i / 2;
else nya -= (i + 1) / 2;
if (calc_f(nya) == 0) {
ans.push_back((long long)nya);
break;
}
}
double q = 1;
double w = a + ans[0];
double h = ans[0] * ans[0] + ans[0] * a + b;
double topper = -1 * w + sqrt(w*w - 4 * q*h);
topper /= 2 * q;
ans.push_back((long long)(topper));
topper = -1 * w - sqrt(w*w - 4 * q*h);
topper /= 2 * q;
ans.push_back((long long)(topper));
sort(ans.begin(), ans.end());
cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
return 0;
}
kotamanegi