As Valeric and Valerko were watching one of the last Euro Championship games in a sports bar, they broke a mug. Of course, the guys paid for it but the barman said that he will let them watch football in his bar only if they help his son complete a programming task. The task goes like that.
Let's consider a set of functions of the following form:
Valeric and Valerko really want to watch the next Euro Championship game, so they asked you to help them.
The first line contains integer n (1 ≤ n ≤ 105) — the number of functions. Each of the following n lines contains two space-separated integer numbers ki, bi ( - 109 ≤ ki, bi ≤ 109) that determine the i-th function.
Print a single number — the number of angles that do not equal 180 degrees in the graph of the polyline that equals the sum of the given functions.
1 1 0
1
3 1 0 0 2 -1 1
2
3 -2 -4 1 7 -5 1
3
题解:
意思是给你很多根线的k和b,然后线在y=0的下方的全算作y=0,其他的原样,问你有多少条线的夹角不为180度
就是求出每一条线与y=0的交点为(-b/k,0),求出有多少个不同的这样的点就是答案,可以用set或者map
代码:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<stdlib.h>
#include<cmath>
#include<string>
#include<algorithm>
#include<iostream>
#include<stdio.h>
using namespace std;
#define ll long long
map<long double,int>p;
int main()
{
int i,j,n;
int k,b;
scanf("%d",&n);
while(n--)
{
scanf("%d%d",&k,&b);
if(k)
{
p[(long double)-b/k]=1;
}
}
printf("%d\n",p.size());
return 0;
}