結果

問題 No.75 回数の期待値の問題
ユーザー imgry22imgry22
提出日時 2014-12-11 18:43:00
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,170 ms / 5,000 ms
コード長 579 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 51,860 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 14:00:35
合計ジャッジ時間 10,291 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
4,376 KB
testcase_01 AC 81 ms
4,380 KB
testcase_02 AC 82 ms
4,380 KB
testcase_03 AC 123 ms
4,376 KB
testcase_04 AC 82 ms
4,380 KB
testcase_05 AC 82 ms
4,376 KB
testcase_06 AC 81 ms
4,376 KB
testcase_07 AC 128 ms
4,380 KB
testcase_08 AC 133 ms
4,380 KB
testcase_09 AC 139 ms
4,376 KB
testcase_10 AC 148 ms
4,376 KB
testcase_11 AC 160 ms
4,376 KB
testcase_12 AC 177 ms
4,380 KB
testcase_13 AC 185 ms
4,380 KB
testcase_14 AC 195 ms
4,376 KB
testcase_15 AC 247 ms
4,376 KB
testcase_16 AC 940 ms
4,376 KB
testcase_17 AC 1,675 ms
4,380 KB
testcase_18 AC 2,010 ms
4,380 KB
testcase_19 AC 2,170 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
using namespace std;

#define rrep(i, m, n) for(int i=m; i<n; i++)
#define erep(i, m, n) for(int i=m; i<=n; i++)
#define  rep(i, n)    for(int i=0; i<n; i++)

#define CNT 1E6

int k;
double res;

int main()
{
  cin >> k;

  srand((unsigned)time(NULL));

  rep(j, CNT){
    int sum = 0;
    rep(i, CNT){
      sum += rand()%6+1;
      if(sum == k){
        res += i+1;
        break;
      }
      if(sum > k) sum = 0;
    }
  }

  printf("%.10f\n", res/CNT);

  return 0;
}
0