# 【2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛】A题 Fruit Ninja ---- 共线+随机数

AC代码：

#include<bits/stdc++.h>
#define rep(i,s,t) for(int i = (int)(s); i <= (int)(t); i++)
#define rev(i,t,s) for(int i = (int)(t); i >= (int)(s); i--)
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
const int maxn = 1e6+5;
struct Point
{
int x,y;
};
Point p[maxn];
bool judge_on_line(Point a,Point b,Point c)//斜率公式
{
return (c.x-a.x)*(b.y-a.y)==(b.x-a.x)*(c.y-a.y);
}
void init()
{
srand((unsigned)time(NULL));
}
int main()
{
#ifdef LOCAL_FILE
freopen("in.txt","r",stdin);
#endif // LOCAL_FILE
ios_base::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
init();
int t;
cin>>t;
while(t--)
{
int n;
int flag = 1;
double x;
cin>>n>>x;
for(int i=1;i<=n;i++)
cin>>p[i].x>>p[i].y;
for(int i=0;i<250;i++)
{
int p1 = rand()%(n+1);
int p2 = rand()%(n+1);
if(p1 == p2) continue;
if(p1<1 || p2<1 || p1>n || p2>n) continue;
int m = 2;
for(int j=1;j<=n;j++)
{
if(j == p1 || j == p2) continue;
if(judge_on_line(p[p1],p[p2],p[j])) m++;
}
if((m*1.0/n) >= x)
{
flag = 0;
break;
}
}
if(flag)
cout<<"No"<<endl;
else
cout<<"Yes"<<endl;
}
return 0;
}