Language: C++

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-7;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

struct Point {
  double x, y;
  Point() {;}
  Point(double x, double y) : x(x), y(y) {;}
  bool operator<(const Point &rhs) const {
    if (fabs(x - rhs.x) > EPS) { return x < rhs.x; }
    if (fabs(y - rhs.y) > EPS) { return y > rhs.y; }
    return false;
  }
};

int n;
double A,B,C,D,E,F;
double la[30];
double lb[30];
double lc[30];
int node;
int edge;
int hit;
set<Point> points;

double X(double a, double b, double c, double y) {
  assert(fabs(a) > EPS);
  return (-b * y - c) / a;
}

double Y(double a, double b, double c, double x) {
  assert(fabs(b) > EPS);
  return (-a * x - c) / b;
}

vector<Point> CurveLine(int i) {
  bool swaped = false;
  double a1 = A;
  double b1 = B;
  double c1 = C;
  double d1 = D;
  double e1 = E;
  double f1 = F;
  double d2 = la[i];
  double e2 = lb[i];
  double f2 = lc[i];
  if (e2 == 0) {
    swap(a1, c1);
    swap(d1, e1);
    swap(d2, e2);
    swaped = true;
  }
  double P = a1 * e2 * e2 - b1 * e2 * d2 + c1 * d2 * d2;
  double Q = -b1 * e2 * f2 + 2 * c1 * d2 * f2 + d1 * e2 * e2 - e1 * e2 * d2;
  double R = c1 * f2 * f2 - e1 * e2 * f2 + f1 * e2 * e2;
  vector<Point> ret;
  double D = Q * Q - 4 * P * R;
  if (P == 0) {
    double x = -R / Q;
    ret.push_back(Point(x, Y(d2, e2, f2, x)));
  } else if (fabs(D) <= EPS){
    double x = -Q / (2 * P);
    ret.push_back(Point(x, Y(d2, e2, f2, x)));
  } else if (D > 0) {
    double x = (-Q + sqrt(D)) / (2 * P);
    ret.push_back(Point(x, Y(d2, e2, f2, x)));
    x = (-Q - sqrt(D)) / (2 * P);
    ret.push_back(Point(x, Y(d2, e2, f2, x)));
  }
  if (swaped) {
    FORIT(it, ret) { swap(it->x, it->y); }
  }
  return ret;
}

vector<Point> LineLine(int i, int j) {
  double a1 = la[i];
  double b1 = lb[i];
  double c1 = lc[i];
  double a2 = la[j];
  double b2 = lb[j];
  double c2 = lc[j];
  vector<Point> ret;
  if (fabs(a1 * b2 - a2 * b1) > EPS) {
    ret.push_back(Point((-b2 * c1 + b1 * c2) / (a1 *b2 - a2 * b1), (a2 * c1 - a1 * c2) / (a1 * b2 - a2 * b1)));
  }
  return ret;
}

int CntCurve() {
  int ret = 0;
  FORIT(it, points) {
    double x = it->x;
    double y = it->y;
    if (fabs(A * x * x + B * x * y + C * y * y + D * x + E * y + F) <= EPS) { ret++; }
  }
  return ret;
}

int CntLine(int i) {
  int ret = 0;
  FORIT(it, points) {
    if (fabs(la[i] * it->x + lb[i] * it->y + lc[i]) <= EPS) { ret++; }
  }
  return ret;
}

int main() {
  while (scanf("%d", &n) > 0) {
    points.clear();
    hit = 1;
    node = 0;
    edge = 0;
    scanf("%lf %lf %lf %lf %lf %lf", &A, &B, &C, &D, &E, &F);
    {
      int m = 0;
      REP(i, n) {
        scanf("%lf %lf %lf", &la[m], &lb[m], &lc[m]);
        REP(j, m) {
          if (fabs(la[j] * lb[m] - la[m] * lb[j]) <= EPS) {
            if ((la[j] != 0 && fabs(la[j] * lc[m] - la[m] * lc[j]) <= EPS) ||
                (lb[j] != 0 && fabs(lb[j] * lc[m] - lb[m] * lc[j]) <= EPS)) {
              m--;
              break;
            }
          }
        }
        m++;
      }
      n = m;
    }
    REP(i, n) {
      vector<Point> ps = CurveLine(i);
      FORIT(it, ps) { points.insert(*it); }
      REP(j, i) {
        vector<Point> ps = LineLine(i, j);
        FORIT(it, ps) { points.insert(*it); }
      }
    }
    node = points.size();
    edge += CntCurve();
    if (fabs(B * B - 4 * A * C) <= EPS) {
      edge++;
    } else if (B * B - 4 * A * C < 0) {
      if (CntCurve() == 0) { hit = 0; }
    } else {
      edge += 2;
    }
    REP(i, n) {
      edge += CntLine(i) + 1;
    }
    printf("%d\n", edge - node + 1 + (1 - hit));
  }
}
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-7;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

struct Point {
  double x, y;
  Point() {;}
  Point(double x, double y) : x(x), y(y) {;}
  bool operator<(const Point &rhs) const {
    if (fabs(x - rhs.x) > EPS) { return x < rhs.x; }
    if (fabs(y - rhs.y) > EPS) { return y > rhs.y; }
    return false;
  }
};

int n;
double A,B,C,D,E,F;
double la[30];
double lb[30];
double lc[30];
int node;
int edge;
int hit;
set<Point> points;

double X(double a, double b, double c, double y) {
  assert(fabs(a) > EPS);
  return (-b * y - c) / a;
}

double Y(double a, double b, double c, double x) {
  assert(fabs(b) > EPS);
  return (-a * x - c) / b;
}

vector<Point> CurveLine(int i) {
  bool swaped = false;
  double a1 = A;
  double b1 = B;
  double c1 = C;
  double d1 = D;
  double e1 = E;
  double f1 = F;
  double d2 = la[i];
  double e2 = lb[i];
  double f2 = lc[i];
  if (e2 == 0) {
    swap(a1, c1);
    swap(d1, e1);
    swap(d2, e2);
    swaped = true;
  }
  double P = a1 * e2 * e2 - b1 * e2 * d2 + c1 * d2 * d2;
  double Q = -b1 * e2 * f2 + 2 * c1 * d2 * f2 + d1 * e2 * e2 - e1 * e2 * d2;
  double R = c1 * f2 * f2 - e1 * e2 * f2 + f1 * e2 * e2;
  vector<Point> ret;
  double D = Q * Q - 4 * P * R;
  if (P == 0) {
    double x = -R / Q;
    ret.push_back(Point(x, Y(d2, e2, f2, x)));
  } else if (fabs(D) <= EPS){
    double x = -Q / (2 * P);
    ret.push_back(Point(x, Y(d2, e2, f2, x)));
  } else if (D > 0) {
    double x = (-Q + sqrt(D)) / (2 * P);
    ret.push_back(Point(x, Y(d2, e2, f2, x)));
    x = (-Q - sqrt(D)) / (2 * P);
    ret.push_back(Point(x, Y(d2, e2, f2, x)));
  }
  if (swaped) {
    FORIT(it, ret) { swap(it->x, it->y); }
  }
  return ret;
}

vector<Point> LineLine(int i, int j) {
  double a1 = la[i];
  double b1 = lb[i];
  double c1 = lc[i];
  double a2 = la[j];
  double b2 = lb[j];
  double c2 = lc[j];
  vector<Point> ret;
  if (fabs(a1 * b2 - a2 * b1) > EPS) {
    ret.push_back(Point((-b2 * c1 + b1 * c2) / (a1 *b2 - a2 * b1), (a2 * c1 - a1 * c2) / (a1 * b2 - a2 * b1)));
  }
  return ret;
}

int CntCurve() {
  int ret = 0;
  FORIT(it, points) {
    double x = it->x;
    double y = it->y;
    if (fabs(A * x * x + B * x * y + C * y * y + D * x + E * y + F) <= EPS) { ret++; }
  }
  return ret;
}

int CntLine(int i) {
  int ret = 0;
  FORIT(it, points) {
    if (fabs(la[i] * it->x + lb[i] * it->y + lc[i]) <= EPS) { ret++; }
  }
  return ret;
}

int main() {
  while (scanf("%d", &n) > 0) {
    points.clear();
    hit = 1;
    node = 0;
    edge = 0;
    scanf("%lf %lf %lf %lf %lf %lf", &A, &B, &C, &D, &E, &F);
    {
      int m = 0;
      REP(i, n) {
        scanf("%lf %lf %lf", &la[m], &lb[m], &lc[m]);
        REP(j, m) {
          if (fabs(la[j] * lb[m] - la[m] * lb[j]) <= EPS) {
            if ((la[j] != 0 && fabs(la[j] * lc[m] - la[m] * lc[j]) <= EPS) ||
                (lb[j] != 0 && fabs(lb[j] * lc[m] - lb[m] * lc[j]) <= EPS)) {
              m--;
              break;
            }
          }
        }
        m++;
      }
      n = m;
    }
    REP(i, n) {
      vector<Point> ps = CurveLine(i);
      FORIT(it, ps) { points.insert(*it); }
      REP(j, i) {
        vector<Point> ps = LineLine(i, j);
        FORIT(it, ps) { points.insert(*it); }
      }
    }
    node = points.size();
    edge += CntCurve();
    if (fabs(B * B - 4 * A * C) <= EPS) {
      edge++;
    } else if (B * B - 4 * A * C < 0) {
      if (CntCurve() == 0) { hit = 0; }
    } else {
      edge += 2;
    }
    REP(i, n) {
      edge += CntLine(i) + 1;
    }
    printf("%d\n", edge - node + 1 + (1 - hit));
  }
}

Compiler output:
a.cc:192:21: error: redefinition of 'const double EPS'
  192 | static const double EPS = 1e-7;
      |                     ^~~
a.cc:17:21: note: 'const double EPS' previously defined here
   17 | static const double EPS = 1e-7;
      |                     ^~~
a.cc:193:21: error: redefinition of 'const double PI'
  193 | static const double PI = acos(-1.0);
      |                     ^~
a.cc:18:21: note: 'const double PI' previously defined here
   18 | static const double PI = acos(-1.0);
      |                     ^~
a.cc:201:8: error: redefinition of 'struct Point'
  201 | struct Point {
      |        ^~~~~
a.cc:26:8: note: previous definition of 'struct Point'
   26 | struct Point {
      |        ^~~~~
a.cc:212:5: error: redefinition of 'int n'
  212 | int n;
      |     ^
a.cc:37:5: note: 'int n' previously declared here
   37 | int n;
      |     ^
a.cc:213:8: error: redefinition of 'double A'
  213 | double A,B,C,D,E,F;
      |        ^
a.cc:38:8: note: 'double A' previously declared here
   38 | double A,B,C,D,E,F;
      |        ^
a.cc:213:10: error: redefinition of 'double B'
  213 | double A,B,C,D,E,F;
      |          ^
a.cc:38:10: note: 'double B' previously declared here
   38 | double A,B,C,D,E,F;
      |          ^
a.cc:213:12: error: redefinition of 'double C'
  213 | double A,B,C,D,E,F;
      |            ^
a.cc:38:12: note: 'double C' previously declared here
   38 | double A,B,C,D,E,F;
      |            ^
a.cc:213:14: error: redefinition of 'double D'
  213 | double A,B,C,D,E,F;
      |              ^
a.cc:38:14: note: 'double D' previously declared here
   38 | double A,B,C,D,E,F;
      |              ^
a.cc:213:16: error: redefinition of 'double E'
  213 | double A,B,C,D,E,F;
      |                ^
a.cc:38:16: note: 'double E' previously declared here
   38 | double A,B,C,D,E,F;
      |                ^
a.cc:213:18: error: redefinition of 'double F'
  213 | double A,B,C,D,E,F;
      |                  ^
a.cc:38:18: note: 'double F' previously declared here
   38 | double A,B,C,D,E,F;
      |                  ^
a.cc:214:8: error: redefinition of 'double la [30]'
  214 | double la[30];
      |        ^~
a.cc:39:8: note: 'double la [30]' previously declared here
   39 | double la[30];
      |        ^~
a.cc:215:8: error: redefinition of 'double lb [30]'
  215 | double lb[30];
      |        ^~
a.cc:40:8: note: 'double lb [30]' previously declared here
   40 | double lb[30];
      |        ^~
a.cc:216:8: error: redefinition of 'double lc [30]'
  216 | double lc[30];
      |        ^~
a.cc:41:8: note: 'double lc [30]' previously declared here
   41 | double lc[30];
      |        ^~
a.cc:217:5: error: redefinition of 'int node'
  217 | int node;
      |     ^~~~
a.cc:42:5: note: 'int node' previously declared here
   42 | int node;
      |     ^~~~
a.cc:218:5: error: redefinition of 'int edge'
  218 | int edge;
      |     ^~~~
a.cc:43:5: note: 'int edge' previously declared here
   43 | int edge;
      |     ^~~~
a.cc:219:5: error: redefinition of 'int hit'
  219 | int hit;
      |     ^~~
a.cc:44:5: note: 'int hit' previously declared here
   44 | int hit;
      |     ^~~
a.cc:220:12: error: redefinition of 'std::set<Point> points'
  220 | set<Point> points;
      |            ^~~~~~
a.cc:45:12: note: 'std::set<Point> points' previously declared here
   45 | set<Point> points;
      |            ^~~~~~
a.cc:222:8: error: redefinition of 'double X(double, double, double, double)'
  222 | double X(double a, double b, double c, double y) {
      |        ^
a.cc:47:8: note: 'double X(double, double, double, double)' previously defined here
   47 | double X(double a, double b, double c, double y) {
      |        ^
a.cc:227:8: error: redefinition of 'double Y(double, double, double, double)'
  227 | double Y(double a, double b, double c, double x) {
      |        ^
a.cc:52:8: note: 'double Y(double, double, double, double)' previously defined here
   52 | double Y(double a, double b, double c, double x) {
      |        ^
a.cc:232:15: error: redefinition of 'std::vector<Point> CurveLine(int)'
  232 | vector<Point> CurveLine(int i) {
      |               ^~~~~~~~~
a.cc:57:15: note: 'std::vector<Point> CurveLine(int)' previously defined here
   57 | vector<Point> CurveLine(int i) {
      |               ^~~~~~~~~
a.cc:272:15: error: redefinition of 'std::vector<Point> LineLine(int, int)'
  272 | vector<Point> LineLine(int i, int j) {
      |               ^~~~~~~~
a.cc:97:15: note: 'std::vector<Point> LineLine(int, int)' previously defined here
   97 | vector<Point> LineLine(int i, int j) {
      |               ^~~~~~~~
a.cc:286:5: error: redefinition of 'int CntCurve()'
  286 | int CntCurve() {
      |     ^~~~~~~~
a.cc:111:5: note: 'int CntCurve()' previously defined here
  111 | int CntCurve() {
      |     ^~~~~~~~
a.cc:296:5: error: redefinition of 'int CntLine(int)'
  296 | int CntLine(int i) {
      |     ^~~~~~~
a.cc:121:5: note: 'int CntLine(int)' previously defined here
  121 | int CntLine(int i) {
      |     ^~~~~~~
a.cc:304:5: error: redefinition of 'int main()'
  304 | int main() {
      |     ^~~~
a.cc:129:5: note: 'int main()' previously defined here
  129 | int main() {
      |     ^~~~