HDU 1840 Equations (数学)
title: Equations 数学 杭电1840
tags: [数学]
题目链接
Problem Description
All the problems in this contest totally bored you. And every time you get bored you like playing with quadratic equations of the form aX2 + bX + c = 0. This time you are very curious to know how many real solutions an equation of this type has.
Input
The first line of input contains an integer number Q, representing the number of equations to follow. Each of the next Q lines contains 3 integer numbers, separated by blanks, a, b and c, defining an equation. The numbers are from the interval [-1000,1000].
Output
For each of the Q equations, in the order given in the input, print one line containing the number of real solutions of that equation. Print “INF” (without quotes) if the equation has an infinite number of real solutions.
Sample Input
3
1 0 0
1 0 -1
0 0 0
Sample Output
1
2
INF
分析:
就是判断一个方程的跟的个数,首先应该明白的一点就是,如果要用(b^2-4ac)的值来判断的前提必须是这是一个一元二次方程(即a!=0),
如果a=0且b!=0,也就意味着这是一个一元一次方程,
如果a=0切b=0,如果c!=的话,是没有解的,c=0的话,是INF。
代码:
#include<stdio.h>
int main()
{
int s,a,b,c;
scanf("%d",&s);
while(s--)
{
scanf("%d%d%d",&a,&b,&c);
if(a==0 && b==0 && c==0)
printf("INF\n");
if(a==0 && b==0 && c!=0)
printf("0\n");
else if(a==0 && b!=0)
printf("1\n");
else if(a!=0 && (b*b-4*a*c)>0)
printf("2\n");
else if(a!=0 && (b*b-4*a*c)==0)
printf("1\n");
else if(a!=0 && (b*b-4*a*c)<0)
printf("0\n");
}
return 0;
}
HDU 1840 Equations (数学)的更多相关文章
- HDU 1840 Equations (简单数学 + 水题)(Java版)
Equations 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1840 ——每天在线,欢迎留言谈论. 题目大意: 给你一个一元二次方程组,a(X^2 ...
- hdu 1496 Equations hash表
hdu 1496 Equations hash表 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1496 思路: hash表,将原来\(n^{4}\)降 ...
- hdu 1496 Equations
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1496 Equations Description Consider equations having ...
- HDU 5673 Robot 数学
Robot 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5673 Description There is a robot on the origi ...
- HDU 5914 Triangle 数学找规律
Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, who ...
- HDU 2493 Timer 数学(二分+积分)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2493 题意:给你一个圆锥,水平放置,圆锥中心轴与地面平行,将圆锥装满水,在圆锥某一表面开一个小洞,流出来 ...
- HDU 1568 Fibonacci 数学= = 开篇
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1568 分析:一道数学题 找出斐波那契数列的通项公式,再利用对数的性质就可得到前几位的数 斐波那契通项公 ...
- hdu 4602 Partition 数学(组合-隔板法)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4602 我们可以特判出n<= k的情况. 对于1<= k<n,我们可以等效为n个点排成 ...
- HDU 1030 Delta-wave 数学题解
给出一个数字塔,然后求沿着数字之间的边走,给出两个数字,问其路径最短的长度是多少. 看似一条搜索题目,只是有一定做题经验的人都知道,这个不是搜索题,直接搜索肯定超时. 这个是依据规律计算的数学题目. ...
随机推荐
- 【jQuery】 常用函数
[jQuery] 常用函数 html() : 获取设置元素内的 html,包含标签 text() : 获取设置元素内的文本, 不包含标签 val() : 获取设置 value 值 attr() : 获 ...
- java集合浅谈(一)
一.类库结构图概览 容器对象仅能持有对象引用(对象的指针),而不是Copy对象信息,从网上搜得几张Java中集合类库的结构图,如下所示: 二.解说Collection 2.1 Collection ( ...
- jqgrid-parmNames和jsonReader的使用,以及json的返回格式(转)
prmNames : { page:"page", // 表示请求页码的参数名称 rows:"rows", // 表示请求行数的参数名称 sort: ...
- TortoiseSVN的安装使用
下面分享一篇关于TortoiseSVN的安装以及使用 1.运行TortoiseSVN-1.6.6.17493-win32-svn-1.6.6.msi程序, 开始安装 2.点击Next, 下一步 3.选 ...
- Spark搭档Elasticsearch
Spark与elasticsearch结合使用是一种常用的场景,小编在这里整理了一些Spark与ES结合使用的方法.一. write data to elasticsearch利用elasticsea ...
- Elasticsearch中的DocValues
Elasticsearch最近一段时间非常火,以致于背后的公司都改名为Elastic了,因为Elasticsearch已经不仅限于搜索,反而更多的用在大数据分析场景,所以在公司品牌上开始“去Searc ...
- 论文翻译--StarCraft Micromanagement with Reinforcement Learning and Curriculum Transfer Learning
(缺少一些公式的图或者效果图,评论区有惊喜) (个人学习这篇论文时进行的翻译[谷歌翻译,你懂的],如有侵权等,请告知) StarCraft Micromanagement with Reinforce ...
- LeetCode 36——有效的数独
1. 题目 2. 解答 将数独中数字的 ASCII 码值转化到 0-8 之间作为散列值,建立一个散列表,然后分别逐行.逐列.逐宫(3*3小块)统计每个数字的出现次数,若出现次数大于 1,则数独无效. ...
- Spring Cloud文档地址大全
Spring Cloud:http://cloud.spring.io/spring-cloud-static/spring-cloud.html Spring Cloud Config:http:/ ...
- 基本数据类型的成员变量放在jvm的哪块内存区域里?
几个月前自己提问的一个问题没人回答,现在突然翻到,自己回答下: 问题: 比如class{private int i;}如上代码,之前一直以为基本数据类型都是放在虚拟机栈中的,最近看了<深入理解j ...