hdu 1840

Equations

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 759    Accepted Submission(s): 351


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 a*X 2 + b*X + 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
 

Author
Mugurel Ionut Andreica
 

Source
 

Recommend
lcy


#include <stdio.h>
int main()
{
	int q, a, b, c;
	scanf("%d", &q);
	while (q--)
	{
		scanf("%d%d%d", &a, &b, &c);
		if(a != 0)
		{
			if(b * b - 4 * a * c < 0)
				printf("0\n");
			else if(b * b - 4 * a * c == 0)
				printf("1\n");
			else
				printf("2\n");
		}
		else
		{
			if(b != 0)
				printf("1\n");
			else
			{
				if(c != 0)
					printf("0\n");
				else
					printf("INF\n");
			}
		}
	}
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值