結果
問題 | No.301 サイコロで確率問題 (1) |
ユーザー |
|
提出日時 | 2019-09-10 20:35:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,010 bytes |
コンパイル時間 | 1,490 ms |
コンパイル使用メモリ | 167,984 KB |
実行使用メモリ | 17,088 KB |
最終ジャッジ日時 | 2024-07-02 16:19:46 |
合計ジャッジ時間 | 5,885 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 = 1e20;for (size_t i = 0; i < 100; 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(20) << solve(N) << endl;} else {cout << N + 1 << ".66666666666666666666666" << endl;}}}