Codechef MSTONESマイルストーン

リンク
任意に2点があり、ラインを決定\(\ 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);
    }
}

おすすめ

転載: www.cnblogs.com/cjoierShiina-Mashiro/p/12608842.html