結果
| 問題 |
No.550 夏休みの思い出(1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-07-29 00:52:06 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,751 bytes |
| コンパイル時間 | 1,469 ms |
| コンパイル使用メモリ | 164,260 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-11 05:35:10 |
| 合計ジャッジ時間 | 3,431 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 55 |
コンパイルメッセージ
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);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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;
}