2 条题解
-
1
#include<bits/stdc++.h> using namespace std; int main(){ double a,b,c,t,x,y; cin>>a>>b>>c; t=b*b-4*a*c; x=(-b+sqrt(t))/(2*a);y=(-b-sqrt(t))/(2*a); if(t>0) printf("x1=%.5lf;x2=%.5lf",min(x,y),max(x,y)); if(t==0) printf("x1=x2=%.5lf",x); if(t<0) printf("No answer!"); return 0; } -
0
#include<bits/stdc++.h> using namespace std; int main(){ long double a,b,c; cin >> a >> b >> c; long double s = b * b - 4*a*c; if(s == 0){ long double y = -b/(2*a); cout << "x1=x2=" <<fixed << setprecision(5) << y; }else if(s > 0){ long double z = (-b+sqrt(s))/(2*a); long double o = (-b-sqrt(s))/(2*a); cout << fixed << setprecision(5) << "x1="<<min(o,z) <<';' << "x2=" << max(o,z); }else{ cout << " No answer!"; } return 0; }
- 1
信息
- ID
- 6910
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 1
- 标签
- 递交数
- 20
- 已通过
- 13
- 上传者