2013
12-23

# Equations

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*X2 + b*X + c = 0. This time you are very curious to know how many real solutions an equation of this type has.

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].

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.

3
1 0 0
1 0 -1
0 0 0

1
2
INF

mark：除了利用判别式，还需要注意考虑非二次的情况。

# include <stdio.h>

void work()
{
int a, b, c, delta ;
scanf ("%d%d%d", &a, &b, &c) ;
if (a==0)
if (b == 0)
if (c == 0) puts ("INF") ;
else puts ("0") ;
else puts ("1") ;
else
if (b*b > 4*a*c) puts ("2") ;
else if (b*b == 4*a*c) puts ("1") ;
else puts ("0") ;
}

int main ()
{
int T ;
scanf ("%d", &T) ;
while (T--)
work() ;
return 0 ;
}

1. 有两个重复的话结果是正确的，但解法不够严谨，后面重复的覆盖掉前面的，由于题目数据限制也比较严，所以能提交通过。已更新算法

2. 博主您好，这是一个内容十分优秀的博客，而且界面也非常漂亮。但是为什么博客的响应速度这么慢，虽然博客的主机在国外，但是我开启VPN还是经常响应很久，再者打开某些页面经常会出现数据库连接出错的提示