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 (数学)的更多相关文章

  1. HDU 1840 Equations (简单数学 + 水题)(Java版)

    Equations 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1840 ——每天在线,欢迎留言谈论. 题目大意: 给你一个一元二次方程组,a(X^2 ...

  2. hdu 1496 Equations hash表

    hdu 1496 Equations hash表 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1496 思路: hash表,将原来\(n^{4}\)降 ...

  3. hdu 1496 Equations

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1496 Equations Description Consider equations having ...

  4. HDU 5673 Robot 数学

    Robot 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5673 Description There is a robot on the origi ...

  5. HDU 5914 Triangle 数学找规律

    Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, who ...

  6. HDU 2493 Timer 数学(二分+积分)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2493 题意:给你一个圆锥,水平放置,圆锥中心轴与地面平行,将圆锥装满水,在圆锥某一表面开一个小洞,流出来 ...

  7. HDU 1568 Fibonacci 数学= = 开篇

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1568 分析:一道数学题 找出斐波那契数列的通项公式,再利用对数的性质就可得到前几位的数 斐波那契通项公 ...

  8. hdu 4602 Partition 数学(组合-隔板法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4602 我们可以特判出n<= k的情况. 对于1<= k<n,我们可以等效为n个点排成 ...

  9. HDU 1030 Delta-wave 数学题解

    给出一个数字塔,然后求沿着数字之间的边走,给出两个数字,问其路径最短的长度是多少. 看似一条搜索题目,只是有一定做题经验的人都知道,这个不是搜索题,直接搜索肯定超时. 这个是依据规律计算的数学题目. ...

随机推荐

  1. Spring MVC 开发 配置

    1.首先在web.xml中配置一个DispatcherServlet,并通过<servlet-mapping>指定需要拦截的url. 下面xml中配置一个拦截.html为后缀的url. & ...

  2. jmeter3.2版本如何进行webservice接口功能测试

    jmeter3.2版本之后就没有SOAP/XML-RPC Request插件了,所以没办法直接进行webservice接口的测试. 原理上: Web service一般就是用SOAP协议通过HTTP来 ...

  3. fiddler抓包-简单易操作(二)

    Fiddler抓包简介 原理:fiddler是通过改写HTTP代理,客户端和服务器进行交互时,数据会从他那里通过,来监控和截取数据.我是这样理解的,如果不对,欢迎指正.如下图: 如果想要抓到数据包,首 ...

  4. 第一篇 Python安装与环境变量的配置

    开发语言有很多种,为什么选Python? 先对各种开发语言做个初识和分类如下:高级语言:Python Java.PHP C# Go ruby C++... ---> 字节码低级语言:C.汇编 - ...

  5. 深入Python的类和对象

    多态:不同的子类对象,可以调用相同的父类方法,通过改写父类的方法,产生不同的执行结果 instance和type的区别: instance能够顺延到父类,比对对象与父类是否类型一致.而type只能比对 ...

  6. oracle 数据库字段名与实体类字段名称不匹配的处理方法

    之前公司一直都使用sql server 即使数据库字段名称与实体类名称不相同 可以使用诸如: select id as userId from tb_user 这种写法,可换到了oracle 之后坑爹 ...

  7. 点击查看大图Activity

    1.使用方式 Intent intent = new Intent(FriendCircleActivity.this, ImageGralleryPagerActivity.class);//0,索 ...

  8. CSS position属性---absolute与relative

    详情请点击此链接 http://www.cnblogs.com/polk6/archive/2013/07/26/3214847.html

  9. 【历史】- Unix英雄传:图文细数十五位计算机先驱

    Unix,一款多任务多用户操作系统,最早由AT&T公司员工及合作伙伴在贝尔实验室于1969年开发完成.Unix的衍生及克隆版本包括Berkeley Unix.Minix.Linux.AIX.A ...

  10. stap中的entry函数

    只有在ret probe函数中,在这个函数中才会使用@entry函数去提取变量 是因为ret probe 有什么特殊的吗?在中间这个变量会变化吗? A new operator, @entry, is ...