题目链接:点击打开链接
#include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <iostream> #include <map> #include <set> #include <math.h> using namespace std; #define inf 10000000 #define ll __int64 #define N 2005 ll a,b,c; int main(){ ll i, j; while(cin>>a>>b>>c) { double A = (double)a, B = (double)b, C = (double)c; if(a==0) { if(b==0) { if(c==0)puts("-1"); else puts("0"); continue; } puts("1"); printf("%.10lf\n", (-C)/B); continue; } ll h = b*b-4*a*c; if(h<0){puts("0");continue;} if(h==0) { puts("1"); printf("%.10lf\n",-(B/(2.0*A))); } else { puts("2"); double H = sqrt((double)h); if((-B-H)/(2.0*A) > (-B+H)/(2.0*A)) H *= -1; printf("%.10lf\n%.10lf\n", (-B-H)/(2.0*A), (-B+H)/(2.0*A)); } } return 0; }
CodeForces 20B Equation 水题,布布扣,bubuko.com
原文地址:http://blog.csdn.net/qq574857122/article/details/36028157