結果
| 問題 | No.76 回数の期待値で練習 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-15 16:52:39 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 5,000 ms |
| + 102µs | |
| コード長 | 498 bytes |
| 記録 | |
| コンパイル時間 | 2,598 ms |
| コンパイル使用メモリ | 335,308 KB |
| 実行使用メモリ | 35,964 KB |
| 最終ジャッジ日時 | 2026-08-15 16:53:23 |
| 合計ジャッジ時間 | 2,717 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
cout << fixed << setprecision(15);
vector<int> P = {0, 1, 2, 3, 1, 3, 2};
const int M = 1010101;
vector<double> dp(M, -1);
dp[0] = 0;
auto calc = [&](this auto calc, int x) ->double {
if(dp[x] != -1) return dp[x];
double res = 0;
for(int t = 1; t <= 6; ++t) if(x - t >= 0) res += calc(x - t) * P[t];
return dp[x] = res / 12 + 1;
};
int T;
cin >> T;
while(T--) {
int N;
cin >> N;
cout << calc(N) << "\n";
}
}