Codechef MSTONES Milestones
作者:互联网
Link
任选两个点确定一条直线,有\(\frac1{49}\)的概率正确。
多随机几次就很靠谱了。
#include<cstdio>
#include<cstdlib>
#include<algorithm>
const int N=10007;
int x[N],y[N];
int read(){int x;scanf("%d",&x);return x;}
int main()
{
srand(4396);
for(int n,t=read(),ans;t;--t)
{
n=read(),ans=1;
for(int i=1;i<=n;++i) x[i]=read(),y[i]=read();
for(int k=1,u,v,t;k<=777;ans=std::max(ans,t),++k)
{
u=rand()%n+1,v=rand()%n+1,t=0;
if(u==v) continue;
for(int i=1;i<=n;++i) t+=((x[u]-x[v])*(y[v]-y[i])==(x[v]-x[i])*(y[u]-y[v]));
}
printf("%d\n",ans);
}
}
标签:Milestones,int,srand,read,10007,ans,MSTONES,include,Codechef 来源: https://www.cnblogs.com/cjoierShiina-Mashiro/p/12608842.html