题目:
分析:
数据结构里面找到的题...然而并没想到数据结构解法?...
判有多少种不同的斜率 考虑到浮点数带来的误差,可用最简分数来描述斜率
代码:
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
set<P> s;
int gcd(int a,int b){
// if(b>a) swap(a,b);//交换的话负数会出问题
if(b==0) return a;
else return gcd(b,a%b);
}
int main(){
ios_base::sync_with_stdio(false);
int n,x,y;
int a,b,ans=0;
s.clear();
cin>>n>>x>>y;
while(n--){
cin>>a>>b;
a-=x,b-=y;
int mod=gcd(a,b);
a/=mod;
b/=mod;
P p=P(a,b);
// cout<<p.first<<" "<<p.second<<endl;
if(!s.count(p)) ans++,s.insert(p);
}
cout<<ans<<endl;
return 0;
}