Codeforces--630N--Forecast(方程求解)
Forecast
Crawling in process...
Crawling failed
Time Limit:500MS
Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Description
The Department of economic development of IT City created a model of city development till year 2100.
To prepare report about growth perspectives it is required to get growth estimates from the model.
To get the growth estimates it is required to solve a quadratic equation. Since the Department of economic development of IT City creates realistic models only, that quadratic equation has a solution, moreover there are exactly two different real roots.
The greater of these roots corresponds to the optimistic scenario, the smaller one corresponds to the pessimistic one. Help to get these estimates, first the optimistic, then the pessimistic one.
Input
The only line of the input contains three integers a, b, c ( - 1000 ≤ a, b, c ≤ 1000) — the coefficients of
ax2 + bx + c = 0 equation.
Output
In the first line output the greater of the equation roots, in the second line output the smaller one. Absolute or relative error should not be greater than
10 - 6.
Sample Input
1 30 200
-10.000000000000000
-20.000000000000000
给出了一个一元二次方程A*x^2+b*x+c=0求两个根,从小到大输出
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
double a,b,c;
double ans1,ans2;
cin>>a>>b>>c;
ans1=(-1*b+sqrt(b*b-4*a*c))/(2*a);
ans2=(-1*b-sqrt(b*b-4*a*c))/(2*a);
if(ans1>ans2)
printf("%.8lf\n",ans1),printf("%.8lf\n",ans2);
else
printf("%.8lf\n",ans2),printf("%.8lf\n",ans1);
}
Codeforces--630N--Forecast(方程求解)的更多相关文章
- MATLAB 符号变量表达式 + 方程求解
源代码见文末 部分源代码: % 符号变量 两种表达方式 a=sym('a'); class(a); syms b; b; % 符号常量 c=sym('); c; % 符号表达式 三种表达方式 f1=' ...
- 洛谷——P1689 方程求解
P1689 方程求解 题目描述 给一个方程,形如X+Y=Z或X-Y=Z.给出了其中两个未知数,请求出第三个数.未知数用‘?’表示,等式中也许会出现一些多余的空格. 输入输出格式 输入格式: 一行,方程 ...
- 洛谷 P1689 方程求解
P1689 方程求解 题目描述 给一个方程,形如X+Y=Z或X-Y=Z.给出了其中两个未知数,请求出第三个数.未知数用‘?’表示,等式中也许会出现一些多余的空格. 输入输出格式 输入格式: 一行,方程 ...
- FESTUNG模型介绍—1.对流方程求解
FESTUNG模型介绍-1.对流方程求解 1. 控制方程 对流问题中,控制方程表达式为 \[\partial_t C + \partial_x (u^1 C) + \partial_y (u^2 C) ...
- codeforce 630N Forecast
N. Forecast time limit per test 0.5 seconds memory limit per test 64 megabytes input standard input ...
- 【来自媳妇的需求】PHP实现随机数和方程求解
话说2015.11.06 ,北京下了第一场雪.16年的今天没下雪,但是雾霾还是不小的,帮媳妇整理她工作时,出现了下面的需求,便想到使用PHP来写程序来进行求解. [需求] 1. 给出一个平均值X,反过 ...
- Timus1132(二次剩余方程求解)
题目:http://acm.timus.ru/problem.aspx?space=1&num=1132 题意:就是给出方程,p为素数,求在区间内的解. 这个思路很简单,详见:http://a ...
- ZOJ 3329 One Person Game (经典概率dp+有环方程求解)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3329 题意:现在有三个骰子,分别有k1,k2和k3面,面上的点就是1~ki ...
- HDU 3292 【佩尔方程求解 && 矩阵快速幂】
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=3292 No more tricks, Mr Nanguo Time Limit: 3000/1000 M ...
随机推荐
- 屏蔽scrollview的滚动
外层有scrollview时,手指移动方向跟滚动条方向相同时,会导致scrollview的滚动.此时如果不想滚动的话,可以在要接受ontouch的子视图,或者子子视图中的touch监听里加上v.get ...
- 转载:使用FileReader对象的readAsDataURL方法来读取图像文件
文章转载自:http://blog.okbase.net/jquery2000/archive/1296.html: FileReader对象的readAsDataURL方法可以将读取到的文件编码成D ...
- Linux内存压力测试-memtester工具
*:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...
- 关于java 关键字enum不识别的解决办法
从别人那儿拷贝过来的myeclipse java工程,打开一看标红了一大片,仔细一看,原来是不识别enum关键字,这就有点尴尬了. 我自己重新建了一个java工程,测试了下,假如我在新建工程的时候选择 ...
- (转) Arcgis for js之WKT和GEOMETRY的相互转换
http://blog.csdn.net/gisshixisheng/article/details/44057453 1.wkt简介 WKT(Well-known text)是一种文本标记语言,用于 ...
- 如何给PDF文件添加水印?
在数字化媒体高速发展的今天,信息传播的速度也越来越快,人们常常会在网络上一些有趣的图片,文件,段子诸如此类的东西,人们往往会去下载或转发,但是因为一些因素,导致版权之经常上演,水印呢,其实就给你自己的 ...
- 转:LINQ教程一:LINQ简介
原文地址:https://www.cnblogs.com/dotnet261010/p/8278793.html 一.为什么要使用LINQ 要理解为什么使用LINQ,先来看下面一个例子.假设有一个整数 ...
- python中zip( )的使用
zip函数简单用法 x = [1, 2, 3] y = [4, 5, 6] z = [7, 8, 9] xyz = zip(x,y,z) #得到一个zip对象 xyz #打印结果为<zip ob ...
- Bootstrap练习:可折叠下拉菜单
代码: <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UT ...
- 举枪消灭"烂代码"的实战案例
前言 之前我写过一篇如何少写PHP "烂"代码 https://segmentfault.com/a/11...感觉很多新人对此不太理解.今天以打卡功能为例,去讲解其中的奥秘.那篇 ...