結果
| 問題 | No.58 イカサマなサイコロ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-27 17:07:39 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| + 331µs | |
| コード長 | 984 bytes |
| 記録 | |
| コンパイル時間 | 1,110 ms |
| コンパイル使用メモリ | 217,812 KB |
| 実行使用メモリ | 9,308 KB |
| 最終ジャッジ日時 | 2026-07-12 19:52:43 |
| 合計ジャッジ時間 | 2,259 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N,K; cin >> N >> K;
int n = N*6;
vector<double> P(n+1),Q(n+1);
P.at(0) = 1,Q.at(0) = 1;
for(int i=0; i<N; i++){
for(int p=i*6; p>=i; p--){
P.at(p) /= 6;
for(int d=1; d<=6; d++) P.at(p+d) += P.at(p);
P.at(p) = 0;
}
}
for(int i=0; i<N-K; i++){
for(int p=i*6; p>=i; p--){
Q.at(p) /= 6;
for(int d=1; d<=6; d++) Q.at(p+d) += Q.at(p);
Q.at(p) = 0;
}
}
for(int i=N-K; i<N; i++){
for(int p=i*6; p>=i; p--){
Q.at(p) /= 3;
for(int d=4; d<=6; d++) Q.at(p+d) += Q.at(p);
Q.at(p) = 0;
}
}
for(int i=n-1; i>=0; i--) P.at(i) += P.at(i+1);
double answer = 1;
for(int i=0; i<=n; i++) answer -= P.at(i)*Q.at(i);
cout << fixed << setprecision(20) << answer << endl;
}