結果

問題 No.955 ax^2+bx+c=0
ユーザー chocorusk
提出日時 2019-12-18 19:50:32
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,148 bytes
コンパイル時間 942 ms
コンパイル使用メモリ 111,636 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-18 22:14:08
合計ジャッジ時間 3,315 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 122
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll a, b, c;
	cin>>a>>b>>c;
	if(a==0){
		if(b==0){
			if(c!=0){
				cout<<0<<endl;
			}else{
				cout<<-1<<endl;
			}
		}else{
			cout<<1<<endl;
			printf("%.12lf\n", (double)(-c)/b);
		}
		return 0;
	}
	ll d=b*b-4*a*c;
	if(d==0){
		cout<<1<<endl;
		printf("%.12lf\n", (double)(-b)/(2*a));
	}else if(d<0){
		cout<<0<<endl;
	}else{
		cout<<2<<endl;
      double ans[2];
      if(b>=0) ans[0]=(-b-sqrt((double)d))/(2*a);
      else ans[0]=(-b+sqrt((double)d))/(2*a);
      ans[1]=(double)c/a/ans[0];
      sort(ans, ans+2);
      for(int i=0; i<2; i++) printf("%.12lf\n", ans[i]);
	}
	return 0;
}
0