結果
問題 | No.550 夏休みの思い出(1) |
ユーザー |
|
提出日時 | 2017-07-29 00:35:27 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,740 bytes |
コンパイル時間 | 2,257 ms |
コンパイル使用メモリ | 165,352 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-10 11:14:22 |
合計ジャッジ時間 | 4,619 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 50 WA * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:105:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 105 | scanf("%lld%lld%lld",&a,&b,&c); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define INF 1000000000LL 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; } } for(int i=50;i>=19;i--){ if(res[i]!=0)return; } if(res[18]>=2 || res[18]<0)return; ll get=0; for(int i=17;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); if(flag)return; su=-su; tc=-c/su; 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(int i=1;i<=1000000;i++){ if(c%(ll)i==0){ func(i); } } return 0; }