結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2020-04-17 20:38:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,569 bytes |
| コンパイル時間 | 2,319 ms |
| コンパイル使用メモリ | 195,568 KB |
| 最終ジャッジ日時 | 2025-01-09 19:37:32 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 90 WA * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
struct Precision{
Precision(){
cout<<fixed<<setprecision(30);
}
}precision_beet;
__int128_t abs128(__int128_t val){return val<0?-val:val;}
ostream &operator<<(ostream &os,__int128_t val){
if(ostream::sentry(os)){
__uint128_t tmp=abs128(val);
char buf[64];
char *d=end(buf);
do{
--d;
*d=char(tmp%10+'0');
tmp/=10;
}while(tmp);
if(val<0) *--d='-';
int len=end(buf)-d;
if(os.rdbuf()->sputn(d,len)!=len){
os.setstate(ios_base::badbit);
}
}
return os;
}
istream &operator>>(istream &is,__int128_t &val){
string s;
is>>s;
val=0;
for(int i=0;i<(int)s.size();i++)
if(isdigit(s[i])) val=val*10+s[i]-'0';
if(s[0]=='-') val*=-1;
return is;
}
//INSERT ABOVE HERE
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
__int128_t a,b,c;
cin>>a>>b>>c;
using D = long double;
if(a==0){
if(b==0 and c==0) drop(-1);
if(b==0 and c!=0) drop(0);
cout<<1<<newl;
cout<<D(-c)/D(b)<<newl;
return 0;
}
if(b*b-4*a*c<0) drop(0);
if(b*b-4*a*c==0){
cout<<1<<newl;
cout<<D(-b)/D(2*a)<<newl;
return 0;
}
cout<<2<<newl;
cout<<(D(-b)-sqrt(D(b*b-4*a*c)))/D(2*a)<<newl;
cout<<(D(-b)+sqrt(D(b*b-4*a*c)))/D(2*a)<<newl;
return 0;
}
beet