結果
| 問題 | No.57 ミリオンダイス |
| コンテスト | |
| ユーザー |
dgd1724
|
| 提出日時 | 2016-09-18 12:47:56 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,081 bytes |
| 記録 | |
| コンパイル時間 | 1,287 ms |
| コンパイル使用メモリ | 58,676 KB |
| 実行使用メモリ | 88,100 KB |
| 最終ジャッジ日時 | 2024-11-17 08:52:47 |
| 合計ジャッジ時間 | 67,616 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 TLE * 1 |
| other | TLE * 9 |
ソースコード
//#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;
}
dgd1724