結果

問題 No.550 夏休みの思い出(1)
ユーザー gigimegigime
提出日時 2017-07-28 22:55:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,556 bytes
コンパイル時間 1,968 ms
コンパイル使用メモリ 171,788 KB
実行使用メモリ 14,080 KB
最終ジャッジ日時 2024-04-18 11:11:43
合計ジャッジ時間 8,461 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

double A,B,C;
const double MAX_A = 1e18;
const double EPS = 1e-1;

double f(double x)
{
	return x * x * x + A * x * x + B * x + C;
}

double solve(double l,double r)
{
	if(f(l) >= EPS) swap(l,r);
	FOR(i,0,200){
		double mid = (l + r) / 2.0;
		if(f(mid) >= EPS){
			r = mid;
		}
		else{
			l = mid;
		}
	}
	return (l + r) / 2.0;
}

int main()
{
	scanf("%lf%lf%lf",&A,&B,&C);
	vector<ll> ans(1,solve(-MAX_A,MAX_A));
	while(ans.size() < 3){
		FOR(i,0,ans.size()){
			printf("%lld%s",ll(ans [i] + EPS),i + 1 == ans.size() ? "\n" : " ");
		}
		double x = solve(-MAX_A,ans.front() - 1);
		if(abs(f(x)) < EPS){
			ans.push_back(ll(x * 2) - ll(x));
			sort(ans.begin(),ans.end());
			ans.erase(unique(ans.begin(),ans.end()),ans.end());
		}
		x = solve(ans.back() + 1,MAX_A);
		if(abs(f(x)) < EPS){
			ans.push_back(ll(x * 2) - ll(x));
			sort(ans.begin(),ans.end());
			ans.erase(unique(ans.begin(),ans.end()),ans.end());
		}
		FOR(i,1,ans.size()){
			x = solve(ans [i - 1] + 1,ans [i] - 1);
			if(abs(f(x)) < EPS){
				ans.push_back(ll(x * 2) - ll(x));
				sort(ans.begin(),ans.end());
				ans.erase(unique(ans.begin(),ans.end()),ans.end());
			}
		}
	}

	FOR(i,0,ans.size()){
		printf("%lld%s",ans [i],i + 1 == ans.size() ? "\n" : " ");
	}

	return 0;
}
0