結果

問題 No.76 回数の期待値で練習
ユーザー Kmcode1Kmcode1
提出日時 2014-11-23 23:40:16
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 973 bytes
コンパイル時間 2,104 ms
コンパイル使用メモリ 87,912 KB
実行使用メモリ 7,676 KB
最終ジャッジ日時 2023-08-30 22:25:52
合計ジャッジ時間 8,628 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
using namespace std;
int t;
int n;
long long int countt = 0;
long long int m;
void dfs(int j,int sum,int kai){
	if (j == 6){
		if ((n-sum) % 6 == 0){
			countt++;
			m+=kai+((n-sum)/6);
		}
		return;
	}
	else{
		for (int k = 0; j*k + sum <= n; k++){
			dfs(j + 1, sum + j*k, kai+k);
		}
		return;
	}
}
int main(){
	scanf("%d", &t);
	while (t--){
		m = 0;
		countt = 0;
		scanf("%d", &n);
		dfs(1, 0,0);
		double ans = (double)m / (double)countt;
		printf("%.7f\n", ans);
	}
	return 0;
}
0