結果

問題 No.75 回数の期待値の問題
ユーザー fumofumofunifumofumofuni
提出日時 2020-11-23 00:43:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 495 ms / 5,000 ms
コード長 1,597 bytes
コンパイル時間 1,430 ms
コンパイル使用メモリ 169,916 KB
実行使用メモリ 163,248 KB
最終ジャッジ日時 2023-09-30 23:09:10
合計ジャッジ時間 4,398 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
8,484 KB
testcase_01 AC 85 ms
8,504 KB
testcase_02 AC 122 ms
10,208 KB
testcase_03 AC 21 ms
13,604 KB
testcase_04 AC 16 ms
10,096 KB
testcase_05 AC 18 ms
11,768 KB
testcase_06 AC 17 ms
11,784 KB
testcase_07 AC 21 ms
12,996 KB
testcase_08 AC 24 ms
14,700 KB
testcase_09 AC 24 ms
14,756 KB
testcase_10 AC 28 ms
16,212 KB
testcase_11 AC 28 ms
16,164 KB
testcase_12 AC 30 ms
17,756 KB
testcase_13 AC 32 ms
17,960 KB
testcase_14 AC 36 ms
19,448 KB
testcase_15 AC 45 ms
22,500 KB
testcase_16 AC 219 ms
74,024 KB
testcase_17 AC 495 ms
127,088 KB
testcase_18 AC 279 ms
152,268 KB
testcase_19 AC 299 ms
163,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=(r)-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll k;cin >> k;
    vector<vector<double>> dp(100000,vector<double>(k+1));
    dp[0][0]=1;
    rep(i,100000-1){
        rep(j,k){
            rep(x,6){
                if(x+1+j<=k){
                    dp[i+1][x+1+j]+=dp[i][j]/6;
                }
                else {
                    dp[i+1][0]+=dp[i][j]/6;
                }
            }
        }
    }
    CST(10);
    double ans=0;
    rep(i,100000)ans+=dp[i][k]*i;
    cout << ans <<endl;
    /*rep(i,10){
        rep(j,k){
            cout << dp[i][j] <<" ";
        }
        cout << endl;
    }*/
}
0