結果
| 問題 |
No.301 サイコロで確率問題 (1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-10 20:31:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,004 bytes |
| コンパイル時間 | 1,517 ms |
| コンパイル使用メモリ | 168,672 KB |
| 実行使用メモリ | 6,940 KB |
| 最終ジャッジ日時 | 2024-07-02 16:19:59 |
| 合計ジャッジ時間 | 2,893 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
bool check(long double imid, int 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 = 0; j < 6; j++) {
a[i] += a[i - j - 1] / 6.0L;
}
}
}
return a[N + 6] < imid;
}
long double solve(int N) {
long double imin = 0;
long double imax = 1e20;
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--) {
int N;
cin >> N;
if (N <= 200) {
cout << setprecision(50) << solve(N) << endl;
} else {
cout << N + 1 << ".666666666666666666666666666666666666" << endl;
}
}
}