Submission #169830


Source Code Expand

Copy
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RREP(i,x) for(int i=(x);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)

int n;
long double nCr(int n, int r){
	if(n < r || r < 0) return 0.0;
	r = max(r, n-r);
	long double sum = 1;
	for(int i=n;i>r;i--) sum *= i;
	for(int i=2;i<=n-r;i++) sum /= i;
//	printf("%dC%d = %f\n", n, r, static_cast<double>(sum));
	return sum;
}
long double nPr(int n, int r){
	if(n < r || r < 0) return 0.0;
	long double sum = 1;
	for(int i=n;i>n-r;i--) sum *= i;
//	printf("%dP%d = %f\n", n, r, static_cast<double>(sum));
	return sum;
}

main(){
	cin >> n;
	vector<int> d(n), c(n);
	REP(i,n) cin >> d[i];
	REP(i, n) REP(j, n) if(i!=j && d[i] % d[j] == 0) c[i] ++;
	long double sum = 0;
	REP(i, n) for(int j=0;j<n;j++){ //d[i] is j-th from left
		for(int k=0;k<=c[i]&&k<=j;k+=2){
			long double ret = nPr(c[i], k) * nPr(n-1-c[i], j-k) * nCr(j, k) / nPr(n-1, j);
//			if(ret > 1.0)printf("%d %d %d %f\n", i, j, k, static_cast<double>(ret));
			if(ret > n) ret = n;
			ret /= n;
			sum += ret;
		}
	}
	printf("%.10f", static_cast<double>(sum));
	cout << string(10000, '0') << endl;
	return 0;
}

Submission Info

Submission Time
Task C - コイン
User zerokugi
Language C++ (G++ 4.6.4)
Score 100
Code Size 1549 Byte
Status AC
Exec Time 71 ms
Memory 932 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 99 / 99 1 / 1
Status
AC × 3
AC × 20
AC × 40
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt
Subtask2 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt, subtask2_16.txt, subtask2_17.txt, subtask2_18.txt, subtask2_19.txt, subtask2_20.txt
Case Name Status Exec Time Memory
sample_01.txt AC 21 ms 812 KB
sample_02.txt AC 20 ms 796 KB
sample_03.txt AC 21 ms 928 KB
subtask1_01.txt AC 20 ms 928 KB
subtask1_02.txt AC 21 ms 928 KB
subtask1_03.txt AC 21 ms 748 KB
subtask1_04.txt AC 22 ms 932 KB
subtask1_05.txt AC 21 ms 804 KB
subtask1_06.txt AC 22 ms 924 KB
subtask1_07.txt AC 20 ms 800 KB
subtask1_08.txt AC 21 ms 932 KB
subtask1_09.txt AC 21 ms 792 KB
subtask1_10.txt AC 20 ms 800 KB
subtask1_11.txt AC 21 ms 748 KB
subtask1_12.txt AC 21 ms 928 KB
subtask1_13.txt AC 20 ms 788 KB
subtask1_14.txt AC 21 ms 928 KB
subtask1_15.txt AC 21 ms 808 KB
subtask1_16.txt AC 21 ms 924 KB
subtask1_17.txt AC 21 ms 932 KB
subtask1_18.txt AC 21 ms 932 KB
subtask1_19.txt AC 21 ms 736 KB
subtask1_20.txt AC 21 ms 924 KB
subtask2_01.txt AC 21 ms 924 KB
subtask2_02.txt AC 21 ms 924 KB
subtask2_03.txt AC 21 ms 928 KB
subtask2_04.txt AC 23 ms 800 KB
subtask2_05.txt AC 25 ms 920 KB
subtask2_06.txt AC 22 ms 928 KB
subtask2_07.txt AC 22 ms 924 KB
subtask2_08.txt AC 71 ms 776 KB
subtask2_09.txt AC 68 ms 804 KB
subtask2_10.txt AC 66 ms 800 KB
subtask2_11.txt AC 52 ms 760 KB
subtask2_12.txt AC 51 ms 812 KB
subtask2_13.txt AC 25 ms 796 KB
subtask2_14.txt AC 53 ms 920 KB
subtask2_15.txt AC 51 ms 808 KB
subtask2_16.txt AC 23 ms 804 KB
subtask2_17.txt AC 67 ms 760 KB
subtask2_18.txt AC 21 ms 924 KB
subtask2_19.txt AC 23 ms 808 KB
subtask2_20.txt AC 68 ms 808 KB