結果

問題 No.76 回数の期待値で練習
ユーザー 0w10w1
提出日時 2018-05-08 22:13:42
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 160 ms / 5,000 ms
コード長 569 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 60,288 KB
最終ジャッジ日時 2024-04-21 02:07:50
合計ジャッジ時間 988 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 160 ms
60,288 KB
testcase_01 AC 151 ms
60,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function Main(input) {

  const p = [1.0 / 12, 2.0 / 12, 3.0 / 12, 1.0 / 12, 3.0 / 12, 2.0 / 12];

  let dp = new Array(1e6 + 70).fill(0.0);
  for (let i = 1; i <= 1e6; ++i) {
    for (let j = 1; j <= 6; ++j) {
      dp[10 + i] += (1.0 + dp[10 + i - j]) * p[j - 1];
    }
  }

  let inputs = input.split('\n');

  let t = inputs[0].split(' ').map((e) => e - 0);

  for (let ti = 0; ti < t; ++ti) {
    let n = inputs[1 + ti].split(' ').map((e) => e - 0)[0];
    console.log('%s', dp[10 + n].toFixed(12));
  }

}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
0