题目链接:戳这里
题意:一个平面里有n个点,问存不存在一条直线上有m个点,满足m >= n*x。
解题思路:0
附ac代码:
1 #include
2 #include
3 using namespace std;
4 typedef long long ll;
5 #define lson l,mid,rt<<1
6 #define rson mid+1,r,rt<<1|1
7 #define lef rt<<1
8 #define rig rt<<1|1
9 const int maxn = 2e5 + 10;
10 const ll mod = 998244353;
11 const ll inf = 0x3f3f3f3f;
12 const double eps = 1e-6;
13 struct nod
14 {
15 double x;
16 double y;
17 }coo\[maxn\];
18
19 int main()
20 {
21 int t;
22 scanf("%d", &t);
23 double x;
24 int n;
25 while(t--)
26 {
27
28 scanf("%d %lf", &n, &x);
29 for(int i = 1; i <= n; ++i)
30 {
31 scanf("%lf %lf", &coo\[i\].x, &coo\[i\].y);
32 }
33 int cas = 20;
34 while(cas--)
35 {
36 map
37 int i = rand() % n + 1, j = 1;
38 for(j = 1; j <= n; ++j)
39 {
40 if(i == j)continue;
41 double u;
42 if(fabs(coo[j].x - coo[i].x) < eps)
43 {
44 u = inf + 1.0;
45 ++mp[u];
46 if(mp[u] + 1.0 + eps > n * x) break;
47 }
48 else
49 {
50 u = (coo[i].y - coo[j].y) / (coo[i].x - coo[j].x);
51 ++mp[u];
52 if(mp[u] + 1.0 + eps > n * x) break;
53 }
54 }
55 if(j <= n) break;
56 }
57 if(cas > 0) puts("Yes");
58 else puts("No");
59 }
60 return 0;
61 }
手机扫一扫
移动阅读更方便
你可能感兴趣的文章