結果

問題 No.550 夏休みの思い出(1)
ユーザー kotatsugamekotatsugame
提出日時 2020-03-12 00:07:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,134 bytes
コンパイル時間 913 ms
コンパイル使用メモリ 73,468 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-10 04:35:07
合計ジャッジ時間 3,457 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,384 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,384 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 2 ms
4,384 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 1 ms
4,376 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 1 ms
4,380 KB
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 1 ms
4,380 KB
testcase_54 AC 2 ms
4,376 KB
testcase_55 AC 1 ms
4,376 KB
testcase_56 AC 1 ms
4,376 KB
testcase_57 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:120:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
  120 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
const long BASE=1e9;
const int WD=4;
struct ll
{
	long dat[WD+1];
	ll(long X=0)
	{
		bool neg=false;
		if(X<0)
		{
			neg=true;
			X=-X;
		}
		for(int i=0;i<WD;i++)
		{
			dat[i]=X%BASE;
			X/=BASE;
		}
		dat[WD]=0;
		if(neg)negate();
	}
	bool iszero()
	{
		for(int i=0;i<=WD;i++)if(dat[i]!=0)return false;
		return true;
	}
	bool isneg()
	{
		return dat[WD]==1;
	}
	void negate()
	{
		if(!iszero())
		{
			for(int i=0;i<WD;i++)
			{
				dat[i]=BASE-dat[i]-(i>0);
			}
			dat[WD]=1-dat[WD];
		}
	}
	void add(const ll&B)
	{
		for(int i=0;i<=WD;i++)
		{
			dat[i]+=B.dat[i];
			if(dat[i]>=BASE)
			{
				dat[i]-=BASE;
				dat[i+1]++;
			}
		}
		dat[WD]%=2;
	}
	void mul(ll B)
	{
		bool negflag=false;
		if(isneg())
		{
			negflag=!negflag;
			negate();
		}
		if(B.isneg())
		{
			negflag=!negflag;
			B.negate();
		}
		for(int i=WD-1;i>=0;i--)
		{
			for(int j=WD-1-i;j>0;j--)
			{
				dat[i+j]+=dat[i]*B.dat[j];
			}
			dat[i]*=B.dat[0];
		}
		for(int i=0;i<WD-1;i++)
		{
			dat[i+1]+=dat[i]/BASE;
			dat[i]%=BASE;
		}
		dat[WD-1]%=BASE;
		if(negflag)negate();
	}
};
ll A,B,C;
ll f(long x)
{
	ll X(x);
	ll ret(0L);
	ret.add(C);
	ll BX=X;
	BX.mul(B);
	ret.add(BX);
	ll AX=X;
	AX.mul(X);
	ll XXX=AX;
	AX.mul(A);
	ret.add(AX);
	XXX.mul(X);
	ret.add(XXX);
	return ret;
}
ll D,E;
ll g(long x)
{
	ll X(x);
	ll ret(0L);
	ret.add(E);
	ll DX=X;
	DX.mul(D);
	ret.add(DX);
	ll XX=X;
	XX.mul(X);
	ret.add(XX);
	return ret;
}
main()
{
	long a,b,c;cin>>a>>b>>c;
	A=ll(a);
	B=ll(b);
	C=ll(c);
	long Lx=-1e9,Rx=1e9;
	while(Rx-Lx>1)
	{
		long Mx=(Lx+Rx)/2;
		if(f(Mx).isneg())Lx=Mx;
		else Rx=Mx;
	}
	long alpha=Rx;
	D=ll(a+alpha);
	E=ll(alpha*alpha);
	E.add(B);
	A.mul(ll(alpha));
	E.add(A);
	a+=alpha;
	a=-a;
	long BL=-1e9,BR,CL,CR=1e9;
	if(a%2==0)
	{
		BR=a/2;
		CL=a/2;
	}
	else
	{
		BR=a>=0?a/2+1:a/2;
		CL=a>=0?a/2:a/2-1;
	}
	while(BR-BL>1)
	{
		long BM=(BR+BL)/2;
		if(g(BM).isneg())BR=BM;
		else BL=BM;
	}
	while(CR-CL>1)
	{
		long CM=(CR+CL)/2;
		if(g(CM).isneg())CL=CM;
		else CR=CM;
	}
	long ans[3]={alpha,BL,CR};
	sort(ans,ans+3);
	cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<endl;
}
0