結果

問題 No.301 サイコロで確率問題 (1)
ユーザー tubo28tubo28
提出日時 2015-12-27 01:27:24
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 765 bytes
コンパイル時間 1,383 ms
コンパイル使用メモリ 161,908 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 11:09:00
合計ジャッジ時間 2,922 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 18 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:39:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |         scanf("%lld",&n);
      |         ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ld = long double;

long long n;

// e0を仮定してにぶたん
bool le(const ld e0){
    vector<ld> e(n+1);
    for(int i = n-1; i >= 0; i--){
        for(int j = i+1; j <= i+6; j++){
            if(j > n){
                e[i] += (e0+1) / 6;
            } else {
                e[i] += (e[j]+1) / 6;
            }
        }
    }
    return e0 < e[0];
}

ld solve(){
    if(n > 700) return n + 5./3;
    ld lo = 0;
    ld hi = 1e20;
    for(int _ = 0; _ < 60; ++_){
        ld mid = (lo + hi) / 2;
        if(le(mid)) lo = mid;
        else hi = mid;
    }
    return lo;
}

int main(){
    int t;
    cin >> t;
    while(t--){
        scanf("%lld",&n);
        printf("%.20lf\n", (double)solve());
    }
}
0