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. 小程序如何去掉button组件的边框

    小程序获取用户授权不再支持wx.getUserInfo方法,改为用button获取,格式如下 <button class="btn btn" open-type=" ...

  2. 「日常训练」 Soldier and Number Game (CFR304D2D)

    题意 (Codeforces 546D) 给定一个数x=a!b!" role="presentation">x=a!b!x=a!b!的形式,问其中有几个质因数. 分 ...

  3. Python 3基础教程22-单个列表操作

    本文来介绍列表的操作,先看看单个列表的操作,列表有多个方法.以下多行代码,建议你写一个方法,测试运行一个方法,不然看起来很乱. # 元组操作 x = [5,6,2,1,6,7,2,7,9] # app ...

  4. 第二十五篇 hashlib模块(* *)

    用于加密相关的操作,Python 3.x里代替了md5模块和sha模块,主要提供 SHA1, SHA224, SHA256, SHA384, SHA512 ,MD5 算法. 加密复杂程度: SHA1  ...

  5. Django入门与实战

    第1章 介绍课程目标及学习内容 1-1 课程介绍: 第2章 课前准备 2-1 课前准备: 第3章 开发环境搭建 3-1 开发环境搭建: 第4章 创建项目及应用 4-1 创建项目,并了解项目目录下的部分 ...

  6. Spring Boot 学习随记

    微架构的思想在各大互联网公司越来越普及,特此记录Spring Boot的一些细节问题! 网上spring-boot的教程一堆一堆,就没有必要再详细记录了 1:建议通过Idea 来创建spring-bo ...

  7. resetroot_169route_python2(用于ubuntu12.04和14.04,centos系列)

    #!/usr/bin/python import os import json import subprocess from cloudinit.sources.DataSourceConfigDri ...

  8. HDU 3696 Farm Game(拓扑+DP)(2010 Asia Fuzhou Regional Contest)

    Description “Farm Game” is one of the most popular games in online community. In the community each ...

  9. 关于ubuntu上无法运行cmd markdown

    环境:ubuntu18.04 直接解压完的cmd markdown,直接点击可执行文件运行,没有反应,在通过终端运行,提示:Cannot find required executable ifconf ...

  10. javascript知识总结

    javascript: 面对对象 函数创建方式: 1.工厂模式 function createPerson(name, age, job){ var o = new Object(); //创建工厂对 ...