結果

問題 No.352 カード並べ
ユーザー kongarishisyamokongarishisyamo
提出日時 2016-04-06 16:18:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 900 bytes
コンパイル時間 730 ms
コンパイル使用メモリ 61,480 KB
実行使用メモリ 6,940 KB
最終ジャッジ日時 2024-04-14 22:18:34
合計ジャッジ時間 1,124 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<iostream>
#include<vector>

using namespace std;

#define N 20

int main(){

	long long num_data[N + 1];
	long long one_data[N + 1];
	long long nc;
	long long n;
	double ans_data[N + 1];
	vector<long long> vnum;

	num_data[1] = 1;
	n = 2;

	cin >> nc; 
	
	for (long long i = 2; i <= nc; i++) num_data[i] = n, n *= i + 1;

	one_data[1] = 1;
	for (long long i = 2; i <= nc; i++) one_data[i] = num_data[i - 1] * 2;

	ans_data[1] = 1.0;
	ans_data[2] = 2.0;
	long long w = 2;

	for (long long i = 3; i <= nc; i++){
		for (long long j = 1; j < i - 1; j++){
			vnum.push_back((i - 1)*j);
		}
		ans_data[i] = one_data[i];

		long long c = (num_data[i] - one_data[i]) / vnum.size();
		int s = vnum.size();

		for (long long j = 0; j < s; j++){
			ans_data[i] += vnum[j]*c;
		}
		
		w *= i;
		ans_data[i] /= w;
		ans_data[i] += ans_data[i - 1];
	}

	printf("%.12f\n", ans_data[nc]);
}
0