結果

問題 No.550 夏休みの思い出(1)
ユーザー ryoissyryoissy
提出日時 2017-07-29 00:52:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,751 bytes
コンパイル時間 1,817 ms
コンパイル使用メモリ 164,488 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 13:12:35
合計ジャッジ時間 3,088 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 3 ms
6,944 KB
testcase_13 AC 3 ms
6,944 KB
testcase_14 AC 3 ms
6,944 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 3 ms
6,944 KB
testcase_17 AC 3 ms
6,944 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 3 ms
6,940 KB
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 3 ms
6,940 KB
testcase_25 AC 3 ms
6,940 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 3 ms
6,944 KB
testcase_28 AC 3 ms
6,944 KB
testcase_29 AC 3 ms
6,940 KB
testcase_30 AC 3 ms
6,944 KB
testcase_31 AC 3 ms
6,940 KB
testcase_32 AC 3 ms
6,940 KB
testcase_33 AC 3 ms
6,940 KB
testcase_34 AC 3 ms
6,940 KB
testcase_35 AC 3 ms
6,944 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 3 ms
6,940 KB
testcase_38 AC 3 ms
6,944 KB
testcase_39 AC 3 ms
6,940 KB
testcase_40 AC 3 ms
6,944 KB
testcase_41 AC 3 ms
6,940 KB
testcase_42 AC 4 ms
6,944 KB
testcase_43 AC 3 ms
6,940 KB
testcase_44 AC 3 ms
6,944 KB
testcase_45 AC 3 ms
6,940 KB
testcase_46 AC 3 ms
6,940 KB
testcase_47 AC 3 ms
6,940 KB
testcase_48 AC 2 ms
6,940 KB
testcase_49 AC 2 ms
6,944 KB
testcase_50 AC 3 ms
6,944 KB
testcase_51 AC 3 ms
6,940 KB
testcase_52 AC 3 ms
6,940 KB
testcase_53 AC 3 ms
6,944 KB
testcase_54 AC 3 ms
6,940 KB
testcase_55 AC 3 ms
6,940 KB
testcase_56 AC 3 ms
6,944 KB
testcase_57 AC 3 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:102:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  102 |         scanf("%lld%lld%lld",&a,&b,&c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
#define INF 2000000000LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll a,b,c;
ll data[22];
int cnt[22];
ll minu[3];
ll po[22][62];
int now[22];
int n=0;
bool flag=false;

ll labs(ll x){
	if(x<0LL)return -x;
	return x;
}

ll digit[51];
ll res[51];

void solve(ll B,ll C,ll ge){
	int digi=0;
	ll tmp=B;
	memset(digit,0,sizeof(digit));
	memset(res,0,sizeof(res));
	tmp=labs(tmp);
	while(tmp>0){
		digit[digi]=tmp%10LL;
		tmp/=10LL;
		digi++;
	}
	for(int i=0;i<digi;i++){
		for(int j=0;j<digi;j++){
			res[i+j]+=digit[i]*digit[j];
		}
	}
	for(int i=0;i<=digi*2+5;i++){
		res[i+1]+=res[i]/10LL;
		res[i]=res[i]%10LL;
	}
	C*=4LL;
	digi=0;
	while(C>0){
		res[digi]-=C%10LL;
		C/=10;
		digi++;
	}
	if(C!=0LL){
		C=-C;
	}
	while(C>0){
		res[digi]+=C%10LL;
		C/=10;
		digi++;
	}
	for(int i=0;i<=digi*2+5;i++){
		while(res[i]<0){
			res[i+1]--;
			res[i]+=10;
		}
		if(res[i]>0)res[i+1]+=res[i]/10LL;
		res[i]=res[i]%10LL;
	}
	for(int i=50;i>=21;i--){
		if(res[i]!=0)return;
	}
	if(res[20]>=2 || res[20]<0)return;
	ll get=0;
	for(int i=20;i>=0;i--){
		get*=10LL;
		get+=res[i];
		if(get<0LL)return;
	}
	ll l=-INF,r=INF+1LL;
	while(l+1LL<r){
		ll mid=(l+r)/2LL;
		if(mid*mid<=get)l=mid;
		else r=mid;
	}
	if(l*l!=get)return;
	if((-B+l)%2LL==1)return;
	vector<ll> res;
	res.push_back((-B+l)/2LL);
	res.push_back((-B-l)/2LL);
	res.push_back(ge);
	sort(res.begin(),res.end());
	flag=true;
	printf("%lld %lld %lld\n",res[0],res[1],res[2]);
}

void func(ll su){
	if(flag)return;
	ll tc=-c/su;
	ll tb=a+su;
	solve(tb,tc,su);
}

int main(void){
	scanf("%lld%lld%lld",&a,&b,&c);
	if(c==0LL){
		solve(a,b,0);
		return 0;
	}
	for(ll i=-1000000;i<=1000000;i++){
		if(i*i*i+a*i*i+b*i+c==0LL){
			func(i);
		}
	}
	return 0;
}
0