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 ...
随机推荐
- 1A课程笔记分享_StudyJams_2017
1A课程 概述 课程1A主要讲解了Android UI的三种基本控件:TextView.ImageView以及Button.笔记的主体内容主要根据课程内容的讲解顺序来组织,此外我对一些个人比较感兴趣的 ...
- [Windows Server 2008] 查看ASP.net详细错误信息
★ 欢迎来到[护卫神·V课堂],网站地址:http://v.huweishen.com ★ 护卫神·V课堂 是护卫神旗下专业提供服务器教学视频的网站,每周更新视频. ★ 本节我们将带领大家:查看IIS ...
- How To:配置Linux iSCSI客户端
1.安装客户端 [root@node01 Packages]# rpm -Uvh iscsi-initiator-utils-6.2.0.873-2.el6.x86_64.rpm warning: i ...
- 第十三节:pandas之groupby()分组
1.Series()对象分组 1.1.单级索引 1.2.多级索引 2.DataFrame()对象分组 3.获取一个分组,遍历分组,filter过滤.
- 3 numpy模块
Numpy 什么是Numpy:Numeric Python Numpy模块是Python的一种开源的数值计算扩展. 1 一个强大的N维数组对象Array ...
- 7.2.1 代码测试 doctest
Python标准库 doctest 可以搜索程序中类似于交互式Python代码的文本片段,并运行这些交互式代码来验证是否符合预期结果和功能,常用于Python程序的模块测试. 使用doctest模块测 ...
- 在docker上构建tomcat容器
1.查看docker上的镜像 [root@holly ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mysql 5.6 73829d7b ...
- 学习Spring框架等技术的方向、方法和动机
学习Spring框架最早学习Spring框架是在大二的时候,当时看了几本书,看了一些视频,主要是传智播客的.更多的,还是写代码,单独写Spring的,也有与Struts和Hibernate等框架整合的 ...
- flask运行环境搭建(nginx+gunicorn)
系统:CentOS7.2(阿里云ESC) 1.python版本,使用的是默认的python2.7(或者先安装python3) 2.安装nginx,yum install -y nginx 3.安装vi ...
- js调用ro的webservice
Enabling JavaScript Access on the Server Drop the JavaScriptHttpDispatcher component onto the server ...