The full problem statement is here.
Solution to this problem is :
Solution to this problem is :
#include <bits/stdc++.h>
using namespace std;
struct point {
int x, y;
point (int x, int y) : x(x), y(y) {}
point () {}
void in () {
cin >> x >> y;
}
bool operator < (point p) const {
if(x == p.x) return (y < p.y);
return x < p.x;
}
};
map <point, int> f;
int pos(int x) {
return (x < 0) ? -x : x;
}
point normal(int x, int y) {
if(y < 0) {
x *= -1;
y *= -1;
}
if(y == 0) {
if(x < 0) x *= -1;
}
int d = __gcd(pos(x), pos(y));
return point(x / d, y / d);
}
int main()
{
ios_base :: sync_with_stdio (0);
cin.tie(0);
int n;
cin >> n;
point o;
o.in();
int ans = 0;
for(int i = 1; i <= n; i++) {
point p;
p.in();
p = normal(p.x - o.x, p.y - o.y);
if(f[p] == 0) {
ans += 1;
f[p] = 1;
}
}
cout << ans << endl;
return 0;
}
No comments:
Post a Comment