結果
| 問題 |
No.65 回数の期待値の練習
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-18 13:24:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 551 bytes |
| コンパイル時間 | 898 ms |
| コンパイル使用メモリ | 72,364 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-30 03:59:16 |
| 合計ジャッジ時間 | 1,430 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include <iostream>
#include <sstream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
#define REP(i,first,last) for (int i=first;i<last;++i)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
const int MAX_K = 20;
int K;
vector<float> dp(MAX_K + 4, 0);
int main(){
cin >> K;
dp[K] = 0.0;
dp[K - 1] = 1.0;
for (int i=K-2;i>=0;i--) {
for (int j=1;j<=6;j++) {
dp[i] += dp[i+j] / 6;
}
dp[i] += 1;
}
cout << dp[0] << endl;
}