HDU 1840 数学题



判断一元二次方程axx+b*x+c=0的根的问题 , (a == 0 && b != 0) || (a == 0 && b == 0) || a != 0

#include <cstdio>
#include <iostream>
using namespace std;

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