数学 Codeforces Round #291 (Div. 2) B. Han Solo and Lazer Gun

 

题目传送门

 1 /*  2  水题,就是用三点共线的式子来判断射击次数  3 */  4 #include <cstdio>  5 #include <cmath>  6 #include <string>  7 #include <cstring>  8 #include <iostream>  9 #include <algorithm>  10 #include <map>  11 #include <set>  12 #include <vector>  13 using namespace std;  14  15 const int MAXN = 1e3 + 10;  16 int x[MAXN], y[MAXN];  17 bool used[MAXN];  18  19 int main(void)  20 {  21 //freopen ("B.in", "r", stdin);  22  23 int n, x0, y0;  24  25 while (~scanf ("%d%d%d", &n, &x0, &y0))  26  {  27 memset (used, 0, sizeof (used));  28  29 for (int i=1; i<=n; ++i)  30  {  31 scanf ("%d%d", &x[i], &y[i]);  32 x[i] -= x0; y[i] -= y0;  33  }  34  35 int cnt = 0;  36 for (int i=1; i<=n; ++i)  37  {  38 if (!used[i])  39  {  40 cnt++;  41 for (int j=i; j<=n; ++j)  42  {  43 if (!used[j] && (x[i] * y[j] == x[j] * y[i]))  44 used[j] = 1;  45  }  46  }  47  }  48  49 printf ("%d\n", cnt);  50  }  51  52 return 0;  53 }

 

你可能感兴趣的:(codeforces)