結果
| 問題 |
No.301 サイコロで確率問題 (1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-10 20:33:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,024 bytes |
| コンパイル時間 | 1,568 ms |
| コンパイル使用メモリ | 167,764 KB |
| 実行使用メモリ | 17,208 KB |
| 最終ジャッジ日時 | 2024-07-02 16:20:07 |
| 合計ジャッジ時間 | 5,971 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
bool check(long double imid, long long N) {
long double a[N + 1 + 6] = {};
for (size_t i = 0; i < N + 1 + 6; i++) {
if (i < 6) {
a[i] = imid;
continue;
} else if (i == 6) {
a[i] = 0;
} else {
a[i] += 1.0L;
for (size_t j = 5; 0 <= j; j--) {
a[i] += a[i - j - 1] / 6.0L;
}
}
}
return a[N + 6] < imid;
}
long double solve(long long N) {
long double imin = 0;
long double imax = 1e30;
for (size_t i = 0; i < 1000; i++) {
long double imid = (imin + imax) / 2.0L;
(check(imid, N) ? imax : imin) = imid;
}
return imax;
}
int main() {
int T;
cin >> T;
while (T--) {
long long N;
cin >> N;
if (N <= 200) {
cout << setprecision(50) << solve(N) << endl;
} else {
cout << N + 1 << ".666666666666666666666666666666666666" << endl;
}
}
}