結果

問題 No.58 イカサマなサイコロ
ユーザー DialBirdDialBird
提出日時 2017-02-19 08:14:23
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,115 bytes
コンパイル時間 465 ms
コンパイル使用メモリ 72,176 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 18:57:23
合計ジャッジ時間 1,084 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;

#define REP(i,first,last) for (int i=first;i<last;++i)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)

const int MAX_N = 10;
int N,K;

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

  double taro_dp[N+1][N*6+1];
  double jiro_dp[N+1][N*6+1];

  taro_dp[0][0] = 1;
  jiro_dp[0][0] = 1;

  // 太郎の結果
  for (int i=1;i<=N;++i) {
    for (int j=i;j<=N*6;++j) {
      if (i <= K) {
        for (int k=4;k<=6;++k) {
          jiro_dp[i][j] += jiro_dp[i-1][j-k] / 3;
        }
      } else {
        for (int k=1;k<=6;++k) {
          jiro_dp[i][j] += jiro_dp[i-1][j-k] / 6;
        }
      }
    }
  }

  //二郎の結果
  for (int i=1;i<=N;++i) {
    for (int j=i;j<=N*6;++j) {
      for (int k=1;k<=6;++k) {
        jiro_dp[i][j] += jiro_dp[i-1][j-k] / 6;
      }
    }
  }

  double result = 0;

  for (int i=N;i<=N*6;++i) {
    for (int j=N;j<i;++j) {
      result += taro_dp[N][i] * jiro_dp[N][j];
    }
  }

  cout << result << endl;
}
0