結果

問題 No.574 正多面体サイコロ
ユーザー vjudge1
提出日時 2025-09-24 10:18:21
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 901 bytes
コンパイル時間 1,750 ms
コンパイル使用メモリ 162,320 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-24 10:18:25
合計ジャッジ時間 3,263 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1010;
int F,n,k;
double ans;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// freopen("dice.in","r",stdin);
	// freopen("dice.out","w",stdout);
	cin>>F>>n>>k;
	for(int x=1;x<=F;x++){
		double P1=(double)(F-x)/(double)F;//?
		double P2=1.0/(double)F;//??
		// double P3=(double)F/(double)(x-1);//?
		double P3=1.0-P1-P2;//?
		double s=0.0;
		for(int i=0;i<k;i++){//??????
			for(int j=k-i;j<=n-i;j++){//?????
				int k=n-i-j;//??????
				double p=1.0;
				for(int l=1;l<=i;l++)p*=P1;
				for(int l=1;l<=j;l++)p*=P2;
				for(int l=1;l<=k;l++)p*=P3;
				for(int l=1;l<=n;l++)p*=l;
				for(int l=1;l<=i;l++)p/=(double)l;
				for(int l=1;l<=j;l++)p/=(double)l;
				for(int l=1;l<=k;l++)p/=(double)l;
				s+=p;
			}
		}
		ans+=s*(double)x;
	}
	cout<<fixed<<setprecision(15)<<ans<<"\n";
	return 0;
}
/*

*/
0