結果
| 問題 |
No.58 イカサマなサイコロ
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2018-11-12 17:42:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,005 bytes |
| コンパイル時間 | 2,277 ms |
| コンパイル使用メモリ | 195,648 KB |
| 最終ジャッジ日時 | 2025-01-06 16:33:04 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
struct Precision{
Precision(){
cout<<fixed<<setprecision(12);
}
}precision_beet;
//INSERT ABOVE HERE
signed main(){
int n,k;
cin>>n>>k;
const int MAX = 100;
vector<double> dp1(MAX,0),dp2(MAX,0);
dp1[0]=dp2[0]=1;
for(int i=0;i<n;i++){
vector<double> nx1(MAX,0),nx2(MAX,0);
for(int j=0;j+6<MAX;j++){
if(i<k){
for(int a=1;a<=6;a++){
nx1[j+a]+=dp1[j]/6.0;
nx2[j+(a<4?a+3:a)]+=dp2[j]/6.0;
}
}else{
for(int a=1;a<=6;a++){
nx1[j+a]+=dp1[j]/6.0;
nx2[j+a]+=dp2[j]/6.0;
}
}
}
swap(dp1,nx1);
swap(dp2,nx2);
}
double ans=0;
for(int i=0;i<MAX;i++)
for(int j=i+1;j<MAX;j++)
ans+=dp1[i]*dp2[j];
cout<<ans<<endl;
return 0;
}
beet