結果
問題 |
No.574 正多面体サイコロ
|
ユーザー |
![]() |
提出日時 | 2018-11-26 12:57:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 1,041 bytes |
コンパイル時間 | 2,057 ms |
コンパイル使用メモリ | 194,264 KB |
最終ジャッジ日時 | 2025-01-06 17:42:20 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#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 f,n,k; cin>>f>>n>>k; auto C=[](int n,int k){ double res=1; for(Int i=0;i<k;i++){ res*=n-i; res/=i+1; } return res; }; auto P=[](double x,int n){ double res=1; for(int i=0;i<n;i++) res*=x; return res; }; auto calc= [&](int x)->double{ if(x>f) return 0; double res=0; for(int y=k;y<=n;y++) res+=C(n,y)*P(f-x+1,n-y)*P(x-1,y); return res; }; double ans=0; for(int x=1;x<=f;x++){ double res=calc(x)-calc(x+1); ans+=x*res; } for(int i=0;i<n;i++) ans/=f; cout<<ans+1<<endl; return 0; }