At the beginning of this question, I got a wrong question... after I understood it for a long time ~~ In fact, this is how many inflection points will be generated when these broken lines are stacked...
Suppose the question is given n straight lines .. after superposition, only one line will be displayed... but when the stacked line is not a straight line but a line .. there will be a lot of inflection points after the superposition... n broken lines can be easily obtained .. A line with <= n inflection points is displayed .. according to the question requirements .. there are two possibilities for this <=: 1. the inflection point of a line is the same .. the natural superposition will only reflect this common inflection point. 2. Correction to 180 degrees by overlapping inflection points
Back to the question .. all the broken lines in the question are turned on at y = 0 .. that is, on the X axis .. it depends on how many inflection points are added .. it depends on the inflection point set of these broken lines .. for each line .. so that y = 0 is easy to find x = B/k .. k = 0 .. skip directly .. because it will only make the stacked line parallel to the X axis translation without changing the shape... save These inflection points .. it is the answer to determine the number of inflection points after sorting .. here, because all the broken lines are above the X axis .. therefore, the superimposed inflection point will not be corrected to 180 degrees.
The submit result is WA... tune high accuracy .. over half of the points .. or WA... the precision is 1 e-50 .. it is estimated that double cannot afford this precision .. aim at other people's AC code .. long double is used .. this first use... very eggache...
Program:
[Cpp]
# Include <iostream>
# Include <algorithm>
# Include <stdio. h>
# Include <string. h>
# Include <cmath>
# Include <queue>
# Define OOS 2000000000
# Define ll long
Using namespace std;
Int n;
Long double a [100005];
Int main ()
{
Cin> n;
Int I, m = 0, ans;
Double B, k;
For (I = 1; I <= n; I ++)
{
Cin> k> B;
If (k! = 0) a [++ m] =-(B/k );
}
Sort (a + 1, a + 1 + m );
Ans = 0;
For (I = 2; I <= m; I ++)
If (fabs (a [I]-a [I-1])> 1e-50) ans ++;
If (m) ans ++;
Cout <ans <endl;
Return 0;
}