結果
問題 |
No.58 イカサマなサイコロ
|
ユーザー |
|
提出日時 | 2025-06-27 17:07:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 984 bytes |
コンパイル時間 | 2,023 ms |
コンパイル使用メモリ | 198,852 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-27 17:07:42 |
合計ジャッジ時間 | 2,779 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; }