Submission #169614


Source Code Expand

Copy
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int n;
int cnt = 0;

void solve(vector<int> nums){
	int coins[100];
	rep(k, n) coins[k] = 1;
	for(int j = 0; j < n-1; j++){
		for(int k = j+1; k < n; k++){
			if(nums[k] % nums[j] == 0){
				coins[k] *= -1;
			}
		}
	}

	rep(j, n){
		if(coins[j] == 1) cnt++;
	}

	/*
	rep(j, n){
		cout << nums[j] << " ";
	}
	cout << endl;
	*/

}

void perm(vector<int> nums, int d, int md){
	if(md <= d){
		solve(nums);
		return;
	}
	
	int num = d;
	while(num < md){
		swap(nums[d], nums[num]);
		perm(nums, d+1, md);
		swap(nums[d], nums[num]);
		num++;
	}
	return;
	
}


int main(int argc, char const* argv[])
{
	
	cin >> n;
	vector<int> nums(n);
	rep(i, n) cin >> nums[i];
	
	int fact = 1;
	rep(i, n) fact *= (i+1);
	
	perm(nums, 0, n);

	cout << (double)cnt / fact << endl;


	return 0;
}

Submission Info

Submission Time
Task C - コイン
User nagana
Language C++ (G++ 4.6.4)
Score 99
Code Size 975 Byte
Status WA
Exec Time 2038 ms
Memory 940 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 99 / 99 0 / 1
Status
AC × 2
WA × 1
AC × 20
AC × 20
TLE × 20
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 WA 20 ms 796 KB
sample_02.txt AC 23 ms 808 KB
sample_03.txt AC 21 ms 732 KB
subtask1_01.txt AC 23 ms 808 KB
subtask1_02.txt AC 22 ms 928 KB
subtask1_03.txt AC 22 ms 928 KB
subtask1_04.txt AC 41 ms 748 KB
subtask1_05.txt AC 45 ms 804 KB
subtask1_06.txt AC 25 ms 804 KB
subtask1_07.txt AC 41 ms 812 KB
subtask1_08.txt AC 22 ms 796 KB
subtask1_09.txt AC 23 ms 928 KB
subtask1_10.txt AC 43 ms 736 KB
subtask1_11.txt AC 22 ms 920 KB
subtask1_12.txt AC 39 ms 808 KB
subtask1_13.txt AC 20 ms 800 KB
subtask1_14.txt AC 23 ms 796 KB
subtask1_15.txt AC 44 ms 800 KB
subtask1_16.txt AC 37 ms 796 KB
subtask1_17.txt AC 45 ms 732 KB
subtask1_18.txt AC 44 ms 800 KB
subtask1_19.txt AC 44 ms 800 KB
subtask1_20.txt AC 45 ms 804 KB
subtask2_01.txt TLE 2029 ms 928 KB
subtask2_02.txt TLE 2030 ms 936 KB
subtask2_03.txt TLE 2030 ms 884 KB
subtask2_04.txt TLE 2031 ms 932 KB
subtask2_05.txt TLE 2030 ms 940 KB
subtask2_06.txt TLE 2031 ms 928 KB
subtask2_07.txt TLE 2030 ms 940 KB
subtask2_08.txt TLE 2028 ms 932 KB
subtask2_09.txt TLE 2029 ms 936 KB
subtask2_10.txt TLE 2030 ms 936 KB
subtask2_11.txt TLE 2030 ms 932 KB
subtask2_12.txt TLE 2030 ms 932 KB
subtask2_13.txt TLE 2030 ms 924 KB
subtask2_14.txt TLE 2029 ms 928 KB
subtask2_15.txt TLE 2030 ms 920 KB
subtask2_16.txt TLE 2029 ms 884 KB
subtask2_17.txt TLE 2034 ms 936 KB
subtask2_18.txt TLE 2028 ms 936 KB
subtask2_19.txt TLE 2028 ms 928 KB
subtask2_20.txt TLE 2038 ms 924 KB