結果

問題 No.567 コンプリート
ユーザー canonddurcanonddur
提出日時 2019-04-07 08:54:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 814 bytes
コンパイル時間 748 ms
コンパイル使用メモリ 74,436 KB
実行使用メモリ 112,848 KB
最終ジャッジ日時 2023-09-08 17:20:33
合計ジャッジ時間 4,223 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
constexpr int N_MAX = 1e6;
constexpr int KINDS = 6;
// [i][k]
//    i番目までで (0-indexed), k種類揃っている確率
ld dp[N_MAX+1][KINDS+1] = {0.0};

int main(int argc, char** argv) {
  int N;
  cin >> N;

  dp[0][0] = 1.0;
  for (int i=1; i<=N; i++) {
    for (int k=1; k<=KINDS; k++) {
      dp[i][k] = dp[i-1][k]*double(k)/6.0 +
	         dp[i-1][k-1]*double(6-(k-1))/6.0;
    }
  }

  cout << dp[N][6] << endl;

  return 0;
}
0