AtCoder Beginner Contest 008

Submission #1676973

Source codeソースコード

#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int i = (0);i < (n);++i)
#define rep(i,s,g) for(int i = (s);i < (g);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cerr << v[a][b] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n;
	cin >> n;
	iv v;
	REP(i,n)
	{
		int tmp;
		cin >> tmp;
		v.PB(tmp);
	}
	double ans = 0;
	int kuri = 1;
	rep(i,1,n+1)kuri *= i;
	
	REP(qq,kuri)
	{
		int aa[n] = {};
		next_permutation(ALL(v));
		//SHOW1d(v,v.size());
		REP(i,n)
		{
			rep(j,i+1,n)
			{
				if(v[j] % v[i] == 0)
				{
					aa[j]++;
				}
			}
		}
		REP(i,n)
		{
			if(aa[i] % 2 == 0)ans+=1;
		}
	}
	
	double ret = (double)ans / (double)kuri;
	
	printf("%.9f\n",ret);
		

	
	return 0;
}

Submission

Task問題 C - コイン
User nameユーザ名 seica
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 TLE
Score得点 99
Source lengthソースコード長 1366 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt
Subtask1 99 / 99 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 0 / 1 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask1_01.txt AC 1 ms 256 KB
subtask1_02.txt AC 1 ms 256 KB
subtask1_03.txt AC 1 ms 256 KB
subtask1_04.txt AC 8 ms 256 KB
subtask1_05.txt AC 9 ms 256 KB
subtask1_06.txt AC 2 ms 256 KB
subtask1_07.txt AC 6 ms 256 KB
subtask1_08.txt AC 1 ms 256 KB
subtask1_09.txt AC 1 ms 256 KB
subtask1_10.txt AC 8 ms 256 KB
subtask1_11.txt AC 1 ms 256 KB
subtask1_12.txt AC 6 ms 256 KB
subtask1_13.txt AC 1 ms 256 KB
subtask1_14.txt AC 2 ms 256 KB
subtask1_15.txt AC 10 ms 256 KB
subtask1_16.txt AC 6 ms 256 KB
subtask1_17.txt AC 10 ms 256 KB
subtask1_18.txt AC 11 ms 256 KB
subtask1_19.txt AC 9 ms 256 KB
subtask1_20.txt AC 9 ms 256 KB
subtask2_01.txt AC 726 ms 256 KB
subtask2_02.txt TLE
subtask2_03.txt TLE
subtask2_04.txt AC 1 ms 256 KB
subtask2_05.txt AC 1 ms 256 KB
subtask2_06.txt AC 1 ms 256 KB
subtask2_07.txt AC 1 ms 256 KB
subtask2_08.txt AC 1 ms 256 KB
subtask2_09.txt AC 1 ms 256 KB
subtask2_10.txt AC 1 ms 256 KB
subtask2_11.txt AC 1 ms 256 KB
subtask2_12.txt AC 1 ms 256 KB
subtask2_13.txt AC 1 ms 256 KB
subtask2_14.txt AC 1 ms 256 KB
subtask2_15.txt AC 1 ms 256 KB
subtask2_16.txt AC 1 ms 256 KB
subtask2_17.txt AC 1 ms 256 KB
subtask2_18.txt AC 1 ms 256 KB
subtask2_19.txt AC 1 ms 256 KB
subtask2_20.txt AC 1 ms 256 KB