Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <cmath>
- #include <assert.h>
- #include <vector>
- #include <string>
- #include <map>
- #include <set>
- #include <queue>
- #include <stack>
- #include <cstring>
- #include <algorithm>
- #define sc scanf
- #define pr printf
- #define pb push_back
- #define mp std::make_pair
- #define fr first
- #define se second
- using namespace std;
- typedef std::pair<int, int> pii;
- typedef std::pair<double, double> pdd;
- const int MN = 10010;
- const long long M = -(1LL << 50);
- const long long MAX_LONG = std::numeric_limits<long long>::max();
- const long long MIN_LONG = std::numeric_limits<long long>::min() + (1LL << 54);
- const int MAX_INT = std::numeric_limits<int>::max();
- const int MIN_INT = std::numeric_limits<int>::min();
- int n;
- int a[MN];
- int b[MN] = {0};
- long long sum[MN] = {0};
- int main() {
- //freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
- //freopen("path.in", "r", stdin); freopen("path.out", "w", stdout);
- sc("%d", &n);
- for (int i = 0; i < n; i++) {
- sc("%d", &a[i]);
- }
- sort(a, a + n);
- for(int i = 0; i < n; i++) {
- for (int j = i + 1; j < n; j++) {
- b[ (a[j] - a[i]) ]++;
- }
- }
- sum[0] = b[0];
- for (int i = 1; i < MN; i++) {
- sum[i] = sum[i - 1] + b[i];
- }
- long double ans = 0.0;
- for (int i = 0; i < MN; i++) {
- if (b[i] == 0) {
- continue;
- }
- for (int j = 0; j < i; j++) {
- ans += (1.0L * (sum[i - j - 1] * b[i] * b[j]));
- //pr("%d %d: %Lf %Lf\n", i, j, (1.0 * b[i] * b[j] * sum[i - j - 1]), ans);
- }
- }
- pr("%.10Lf\n", (ans / sum[MN - 1]) / sum[MN - 1] / sum[MN - 1]);
- return 0;
- }
Add Comment
Please, Sign In to add comment