https://acm.ecnu.edu.cn/contest/125/problem/B/

题解:随机题

AC也靠随机???

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG

using namespace std;
typedef long long ll;
int N=50000;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m;
double Rand(double L, double R){
    return L + (R - L) * rand() * 1.0 / RAND_MAX;
}
double x[1000],y[1000];
int main()
{
#ifdef DEBUG
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
    scanf("%d",&n);
    if(n>=730){
        cout << "0" << endl;
        return 0;
    }else{
        double ans=0;
        srand(time(NULL));
        if(n>100)
            N=10000;
        if(n>200)
            N=1000;
        if(n>400)
            N=100;
        for(int i=1;i<=N;i++){
            for(int j=1;j<=n;j++){
                x[j]=Rand(0,1);
                y[j]=Rand(0,1);
            }
            double minl=2;
            for(int j=1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                    minl=min(minl,sqrt((x[k]-x[j])*(x[k]-x[j])+(y[k]-y[j])*(y[k]-y[j])));
                }
            }
            ans+=minl;
        }
        cout<<ans/N<<endl;
    }
    //cout << "Hello world!" << endl;
    return 0;
}