結果

問題 No.65 回数の期待値の練習
ユーザー itezpace
提出日時 2016-08-06 08:36:42
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 8 ms / 5,000 ms
コード長 277 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 54,360 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 02:45:44
合計ジャッジ時間 1,224 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int k;

double calc(int a){
  double e;
  if(a>=k){
    e=0;
  } else {
    e=1;
    for(int i=1; i<=6; ++i){
      e+=calc(a+i)/6;
    }
  }
  return e;
}

int main(){
  cin>>k;
  double x;
  x=calc(0);
  cout<<x<<endl;
  return 0;
}
0