結果
| 問題 | No.76 回数の期待値で練習 |
| コンテスト | |
| ユーザー |
tsutaj
|
| 提出日時 | 2018-01-25 10:37:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 5,000 ms |
| コード長 | 1,686 bytes |
| 記録 | |
| コンパイル時間 | 1,334 ms |
| コンパイル使用メモリ | 99,128 KB |
| 実行使用メモリ | 11,520 KB |
| 最終ジャッジ日時 | 2024-12-26 15:27:34 |
| 合計ジャッジ時間 | 1,928 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 |
ソースコード
// 基本テンプレート
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
double info[7] = {0, 1.0000000000000000, 1.0833333333333333, 1.2569444444444444, 1.5353009259259260, 1.6915991512345676, 2.0513639724794235};
double p[7], dp[1000010];
signed main() {
p[6] = 1.0;
for(int k=2; k<=6; k++) {
double val = info[k] - 1;
for(int x=1; x<k-1; x++) val -= info[k-x] * p[x];
p[k-1] = val;
p[6] -= val;
}
for(int k=1; k<1000010; k++) {
for(int x=1; x<=min(6LL, k); x++) {
dp[k] += p[x] * dp[k-x];
}
dp[k] += 1;
}
int T; scanf("%lld", &T);
while(T--) {
int V; scanf("%lld", &V);
printf("%.12f\n", dp[V]);
}
return 0;
}
tsutaj