結果

問題 No.58 イカサマなサイコロ
コンテスト
ユーザー Rumain831
提出日時 2026-08-09 16:46:55
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.90.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 293 ms / 5,000 ms
+ 810µs
コード長 644 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,968 ms
コンパイル使用メモリ 175,784 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-08-09 16:47:00
合計ジャッジ時間 4,989 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
using ll = long long;

int n, k;
int cnt[2][61];
int a[2][6]={{1,2,3,4,5,6}, {4,4,5,5,6,6}};

void dfs(int step, int sum, int t){
  if(step==n){
    cnt[t][sum]++; return;
  }
  for(int i=0; i<6; i++){
    if(t&&step<k) dfs(step+1, sum+a[1][i], t);
    else dfs(step+1, sum+a[0][i], t);
  }
  return;
}

int main(void){
  cin >> n >> k;
  dfs(0, 0, 0);
  dfs(0, 0, 1);
  for(int i=1; i<=60; i++) cnt[0][i]+=cnt[0][i-1];
  double ans=0, p=1.0/cnt[0][60];
  for(int i=1; i<=60; i++) ans+=p*cnt[1][i]*p*cnt[0][i-1];
  printf("%.10f\n", ans);
  return 0; 
}
0