結果
| 問題 | No.574 正多面体サイコロ |
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2018-11-26 12:59:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 2,000 ms |
| コード長 | 1,035 bytes |
| 記録 | |
| コンパイル時間 | 1,906 ms |
| コンパイル使用メモリ | 194,176 KB |
| 最終ジャッジ日時 | 2025-01-06 17:42:27 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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,n-y)*P(x,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<<endl;
return 0;
}
beet