結果

問題 No.58 イカサマなサイコロ
ユーザー cureskolcureskol
提出日時 2020-03-26 15:06:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,269 ms / 5,000 ms
コード長 744 bytes
コンパイル時間 1,574 ms
コンパイル使用メモリ 168,196 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 12:40:25
合計ジャッジ時間 5,285 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2,269 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 9 ms
4,380 KB
testcase_06 AC 349 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 351 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long
using ld=long double;
int pw(int n,int k){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)res*=n;
    n*=n;
    k>>=1;
  }
  return res;
}

signed main(){
  int n,k;cin>>n>>k;
  vector<int> hu(61,0),ika(61,0);
  for(int i=0;i<pw(6,n);i++){
    int res=0,tmp=i;
    for(int j=0;j<n;j++){
      res+=tmp%6+1;
      tmp/=6;
    }
    hu[res]++;
  }
  for(int i=0;i<pw(6,n);i++){
    int res=0,tmp=i;
    for(int j=0;j<n;j++){
      if(j<k)res+=(tmp%3+1)+3;
      else res+=tmp%6+1;
      tmp/=6;
    }
    ika[res]++;
  }
  for(int i=0;i<60;i++)hu[i+1]+=hu[i];
  ld ans=0;
  for(int i=1;i<61;i++)ans+=ika[i]*hu[i-1];
  cout<<fixed<<setprecision(12)<<ans/pw(6,n*2)<<endl;
}
0