参考自:https://www.cnblogs.com/ECJTUACM-873284962/p/6394836.html

1541 - Student’s question

时间限制:1秒 内存限制:128兆

题目描述

YY is a student. He is tired of calculating the quadratic equation. He wants you to help him to get the result of the quadratic equation. The quadratic equation’ format is as follows: ax^2+bx+c=0.

输入

The first line contains a single positive integer N, indicating the number of datasets. The next N lines are n datasets. Every line contains three integers indicating integer numbers a,b,c (a≠0).

输出

For every dataset you should output the result in a single line. If there are two same results, you should just output once. If there are two different results, you should output them separated by a space. Be sure the later is larger than the former. Output the result to 2 decimal places. If there is no solution, output “NO”.

输入 

3

1 2 1

1 2 3

1 -9 6

输出

-1.00

NO

0.73 8.27

解法:
 #include <bits/stdc++.h>
using namespace std;
int main()
{
double n,a,b,c;
while(cin>>n)
{
while(n--)
{
cin>>a>>b>>c;
if(a==)break;
else
{
if(b*b-*a*c>=)
{
double t1=(-b)/a;
double t2=c/a;
double t3=sqrt(t1*t1-*t2);
double x1=(t1+t3)/;
double x2=(t1-t3)/;
if(x1==x2) cout<<fixed<<setprecision()<<x1<<endl;
else if(x1<x2)
cout<<fixed<<setprecision()<<x1<<" "<<x2<<endl;
else if(x1>x2)
cout<<fixed<<setprecision()<<x2<<" "<<x1<<endl;
}
else cout<<"NO"<<endl;
}
}
}
return ;
}

HUST 1541 解方程的更多相关文章

  1. vijos P1915 解方程 加强版

    背景 B酱为NOIP 2014出了一道有趣的题目, 可是在NOIP现场, B酱发现数据规模给错了, 他很伤心, 哭得很可怜..... 为了安慰可怜的B酱, vijos刻意挂出来了真实的题目! 描述 已 ...

  2. HDU 4793 Collision --解方程

    题意: 给一个圆盘,圆心为(0,0),半径为Rm, 然后给一个圆形区域,圆心同此圆盘,半径为R(R>Rm),一枚硬币(圆形),圆心为(x,y),半径为r,一定在圆形区域外面,速度向量为(vx,v ...

  3. codevs3732==洛谷 解方程P2312 解方程

    P2312 解方程 195通过 1.6K提交 题目提供者该用户不存在 标签数论(数学相关)高精2014NOIp提高组 难度提高+/省选- 提交该题 讨论 题解 记录   题目描述 已知多项式方程: a ...

  4. [NOIP2014]解方程

    3732 解方程  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题解       题目描述 Description 输入描述 Input Descrip ...

  5. bzoj 3751: [NOIP2014]解方程 同余系枚举

    3.解方程(equation.cpp/c/pas)[问题描述]已知多项式方程:a ! + a ! x + a ! x ! + ⋯ + a ! x ! = 0求这个方程在[1, m]内的整数解(n 和 ...

  6. Ural 1046 Geometrical Dreams(解方程+计算几何)

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1046 参考博客:http://hi.baidu.com/cloudygoose/item ...

  7. 2017广东工业大学程序设计竞赛决赛 题解&源码(A,数学解方程,B,贪心博弈,C,递归,D,水,E,贪心,面试题,F,贪心,枚举,LCA,G,dp,记忆化搜索,H,思维题)

    心得: 这比赛真的是不要不要的,pending了一下午,也不知道对错,直接做过去就是了,也没有管太多! Problem A: 两只老虎 Description 来,我们先来放松下,听听儿歌,一起“唱” ...

  8. 5.5Python数据处理篇之Sympy系列(五)---解方程

    目录 目录 前言 (一)求解多元一次方程-solve() 1.说明: 2.源代码: 3.输出: (二)解线性方程组-linsolve() 1.说明: 2.源代码: 3.输出: (三)解非线性方程组-n ...

  9. python 解方程

    [怪毛匠子=整理] SymPy 库 安装 sudo pip install sympy x = Symbol('x') 解方程 solve([2 * x - y - 3, 3 * x + y - 7] ...

随机推荐

  1. Python_列表推导式_生成器的表达式_各种推导式_40

    列表推导式: #列表推导式: egg_list = [] for i in range(10): egg_list.append('鸡蛋%s'%i) print(egg_list) egon egg_ ...

  2. 出题人的RP值(牛客练习赛38--A题)(排序)

    链接:https://ac.nowcoder.com/acm/contest/358/A来源:牛客网 题目描述 众所周知,每个人都有自己的rp值(是个非负实数),膜别人可以从别人身上吸取rp值. 然而 ...

  3. Redis缓存用起来

    Redis缓存用起来 1. 引言 创建任务时我们需要指定分配给谁,Demo中我们使用一个下拉列表用来显示当前系统的所有用户,以供用户选择.我们每创建一个任务时都要去数据库取一次用户列表,然后绑定到用户 ...

  4. 如何命名Java变量

    如同酒店会给每个房间起个性化的名字一样,程序中的变量也需要用合理的名字进行管理--变量名! 需要注意,给酒店房间起名字时可以是数字,如“802”,也可以是有趣的名字,如“牡丹”.“美国总统”.“水帘洞 ...

  5. Java对象的创建、内存布局和访问定位

    在Java运行时数据区中,我们知道了虚拟机内存的概况,本文介绍虚拟机内存中的数据的其它细节,如对象如何创建.如何布局以及如何访问. 基于实用的原则,这里以HotSpot虚拟机和常用的内存区域Java堆 ...

  6. Linux 典型应用之常用命令

    软件操作相关命令 软件包管理 (yum) 安装软件 yum install xxx(软件的名字) 如 yum install vim 卸载软件 yum remove xxx(软件的名字) 如 yum ...

  7. js对input框的可编辑属性设置

    添加disabled属性 $('#areaSelect').attr("disabled",true); $('#areaSelect').attr("disabled& ...

  8. Angular ngRepea

    <!DOCTYPE html><html ng-app><head lang="en"> <meta charset="UTF- ...

  9. 你不知道的JavaScript——第一章:作用域是什么?

    编译原理 JavaScript事实上是一门编译语言,但与传统的编译语言不同,它不是提前编译的,编译结果也不能在分布式系统中进行移植. 任何JavaScript代码片段在执行前都要进行编译(通常就在执行 ...

  10. Window上安装—Docker 笔记

    本文转自:http://cnodejs.org/topic/55a24267419f1e8a23a64367 需求 想玩nodeClub 源码跑起来,结果window 上各种报错,各种依赖软件要装的感 ...