結果

問題 No.57 ミリオンダイス
ユーザー dgd1724dgd1724
提出日時 2016-09-18 12:47:56
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,081 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 59,488 KB
実行使用メモリ 44,316 KB
最終ジャッジ日時 2024-04-28 15:36:18
合計ジャッジ時間 12,946 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

//#define _USE_MATH_DEFINES	//M_PI
#include <iostream>			//std::cout, std::cin
//#include <string>			//std::string
//#include <vector>			//std::vector
//#include <valarray>			//std::valarray	数値のみの一次配列
//#include <algorithm>		//std::sort
//#include <time.h>			//localtime_s
//#include <cstdlib>			//abs
#include <cmath>			//abs, std::pow, sqrt, sin, cos,
//#include <fstream>			//std::ifstream
//#include <iomanip>			//std::setprecision
//#include <random>			//std::random(C++11)

void Count_Hit(int N, int target, int *sum, int *hit) {

	for (int i = 0; i < 6; i++) {
		*sum = *sum + 1;
		if (N == 1) {
			if (target == *sum) {
				*hit = *hit + 1;
			}
		}
		else {
			Count_Hit(N - 1, target, sum, hit);
			*sum = *sum - 6 * (N - 1);
		}
	}
}
int main(void) {

	
	//test用
	//std::ifstream in("test.txt");
	//std::cin.rdbuf(in.rdbuf());

	int N = 0;
	std::cin >> N;

	double ans = 0;
	int sum, hit;

	for (int i = 1; i <= 6*N; i++) {
		sum = 0;
		hit = 0;
		Count_Hit(N, i, &sum, &hit);
		ans += i*hit / std::pow(6, N);
	}

	std::cout << ans << std::endl;
}


0