1436 [CA1009]The root of the equation
来源:互联网 发布:姚明nba前几场比赛数据 编辑:程序博客网 时间:2024/06/05 18:45
Description
从键盘读入三个数a, b, c,输出方程ax^2+bx+c=0的两个实根。
Input
三个数a,b,c, 保证方程为一元二次方程,且一定有两个实根。
Output
方程ax^2+bx+c=0的两个实根,小根在前,大根在后, 结果保留到小数点后三位。
Sample Input
1 -4 3
Sample Input
1.000 3.000
Submission
answer.cpp
#include<iostream>#include<iomanip>#include<math.h>using namespace std;int main(){ double a,b,c; cin>>a>>b>>c; cout<<setprecision(3)<<fixed<<(-b-sqrt(b*b-4*a*c))/2/a<<" "<<(-b+sqrt(b*b-4*a*c))/2/a<<endl; return 0;}
Standard Answer
answer.cpp
#include <iostream>#include <iomanip>#include <cmath>using namespace std;int main(){ double a, b, c; cin >> a >> b >> c; double delta = b * b - 4 * a * c; double r1 = (-b - sqrt(delta)) / (2 * a); double r2 = (-b + sqrt(delta)) / (2 * a); cout << fixed << setprecision(3) << r1 << ' ' << r2 << endl; return 0;}
阅读全文
0 0
- 1436 [CA1009]The root of the equation
- The equation
- the root of lisp
- Root of the Problem
- the Root Of AVL
- GCC - the root of all
- 1394. Root of the Problem
- TJU Root of the Problem
- Root of the Problem-3100
- 1394. Root of the Problem
- Jordan Lecture Note-6: The Solutions of Nonlinear Equation.
- 646. Maximum Length of Pair Chain/640. Solve the Equation
- sgu 106 The equation
- SGU 106 The equation
- The equation----扩展欧几里得
- [SGU]106. The Equation
- sgu 106 The equation
- hdu3270 The Diophantine Equation
- AlphaGo技术剖析:揭开围棋大脑的神秘面纱
- 【Unity3d】分享一些Unity3d的小技巧
- SAP HANA Odata的POST报错403 forbidden error
- 第三方支付“躺着赚钱”的时代开始终结
- Java二维数组计算集合(上下左右左斜右斜)
- 1436 [CA1009]The root of the equation
- RC积分(如果叫做低通也行) 俗语
- DQN_tensorflow 源码解读
- K选择问题
- Huge Matrix 扫描
- 硬件访问服务4之Android硬件访问服务框架及系统函数全详细实现
- 搜素-Q
- spring入门(注解实现Bean的定义)
- ubuntu opencv多版本控制