結果
問題 | No.550 夏休みの思い出(1) |
ユーザー |
![]() |
提出日時 | 2017-04-08 16:15:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,953 bytes |
コンパイル時間 | 1,899 ms |
コンパイル使用メモリ | 173,540 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-11 05:30:07 |
合計ジャッジ時間 | 3,702 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 55 |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long LL; #define CIN_ONLY if(1) struct cww{cww(){ CIN_ONLY{ ios::sync_with_stdio(false);cin.tie(0); } }}star; #define fin "\n" #define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() #define fi first #define se second #define pb push_back #define DEBUG if(0) #define REC(ret, ...) std::function<ret (__VA_ARGS__)> template <typename T>inline bool chmin(T &l,T r) {bool a=l>r;if(a)l=r;return a;} template <typename T>inline bool chmax(T &l,T r) {bool a=l<r;if(a)l=r;return a;} template <typename T> istream& operator>>(istream &is,vector<T> &v){ for(auto &it:v)is>>it; return is; } typedef __int128 INT; const INT inf=1e9; const INT INF=1e18; INT getone(INT a,INT b,INT c){ if(c==0)return 0; auto f=[&](INT x){return x*x*x+a*x*x+b*x+c;}; INT ok=-inf,ng=inf; if(f(ok)<0)swap(ok,ng); while(max(ok-ng,ng-ok)>1){ const INT mid=(ok+ng)/2; if(f(mid)<0)ng=mid; else ok=mid; } return ok; } INT gettwo(INT a,INT b){ auto f=[&](INT x){return x*x+a*x+b;}; INT ok=-a/2,ng=inf; if(f(ok)==0)return ok; if(f(ok)<0)swap(ok,ng); while(max(ok-ng,ng-ok)>1){ const INT mid=(ok+ng)/2; if(f(mid)<0)ng=mid; else ok=mid; } return ok; } int main(){ LL a,b,c; //xxx+Axx+Bx+C==0 cin>>a>>b>>c; INT A(a),B(b),C(c); vector<LL> res; res.pb((LL)getone(A,B,C)); //(x-res[0])(xx+Ax+B)==0 A+=res[0];B+=A*res[0]; res.pb((LL)gettwo(A,B)); res.pb((LL)(B/res[1])); sort(ALL(res)); cout<<res[0]<<" "<<res[1]<<" "<<res[2]<<endl; //---------------------------- assert(-INF<a&&a<INF); assert(-INF<b&&b<INF); assert(-INF<c&&c<INF); REP(i,3)assert(-inf<res[i]&&res[i]<inf); REP(i,2)assert(res[i]!=res[i+1]); //---------------------------- return 0; }