B. Han Solo and Lazer Gun 暴力 水

B. Han Solo and Lazer Gun
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.

Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0, y0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x0, y0).

Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers.

The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location.

Input

The first line contains three integers nx0 и y0 (1 ≤ n ≤ 1000,  - 104 ≤ x0, y0 ≤ 104) — the number of stormtroopers on the battle field and the coordinates of your gun.

Next n lines contain two integers each xiyi ( - 104 ≤ xi, yi ≤ 104) — the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point.

Output

Print a single integer — the minimum number of shots Han Solo needs to destroy all the stormtroopers.

蛮水的,直接n^2暴力就好了

 1 #include <algorithm>
 2 #include <stack>
 3 #include <istream>
 4 #include <stdio.h>
 5 #include <map>
 6 #include <math.h>
 7 #include <vector>
 8 #include <iostream>
 9 #include <queue>
10 #include <string.h>
11 #include <set>
12 #include <cstdio>
13 #define FR(i,n) for(int i=0;i<n;i++)
14 #define MAX 2005
15 #define mkp pair <int,int>
16 using namespace std;
17 #include <bits/stdc++.h>
18 const int maxn = 5e5 + 40;
19 typedef long long ll;
20 const int  inf = 0x3fffff;
21 void read(int &x) {
22     char ch; bool flag = 0;
23     for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1); ch = getchar());
24     for (x = 0; isdigit(ch); x = (x << 1) + (x << 3) + ch - 48, ch = getchar());
25     x *= 1 - 2 * flag;
26 }
27 struct inof{
28     int x,y;
29 }p[maxn];
30 int vis[1005];
31 int main() {
32     int n,x,y;
33     read(n),read(x),read(y);
34     for(int i=0;i<n;i++){
35         read(p[i].x),read(p[i].y);
36         p[i].x-=x,p[i].y-=y;
37     }
38     int ans=0;
39     for(int i=0;i<n;i++){
40         if(vis[i])continue;
41         ans++;vis[i]=1;
42         for(int j=0;j<n;j++){
43             if(vis[j])continue;
44             if(p[i].x*p[j].y==p[j].x*p[i].y)vis[j]=1;
45         }
46     }
47     cout<<ans<<endl;
48     return 0;
49 }
我身后空无一人,我怎敢倒下
原文地址:https://www.cnblogs.com/DreamKill/p/9452630.html