結果

問題 No.567 コンプリート
コンテスト
ユーザー siman
提出日時 2021-09-09 11:11:37
言語 C++17(clang)
(clang++ 22.1.2 + boost 1.89.0)
コンパイル:
clang++ -O2 -lm -std=c++1z -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 600 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 6,045 ms
コンパイル使用メモリ 148,992 KB
実行使用メモリ 58,496 KB
最終ジャッジ日時 2026-06-03 11:55:39
合計ジャッジ時間 6,534 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:20:13: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   20 |   double dp[N + 1][7];
      |             ^~~~~
main.cpp:20:13: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:17:7: note: declared here
   17 |   int N;
      |       ^
1 warning generated.

ソースコード

diff #
raw source code

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;

  double dp[N + 1][7];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1.0;

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

  cout << fixed << setprecision(10) << dp[N][6] << endl;

  return 0;
}
0