結果

問題 No.574 正多面体サイコロ
ユーザー beetbeet
提出日時 2018-11-26 12:57:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,041 bytes
コンパイル時間 1,971 ms
コンパイル使用メモリ 199,396 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-28 17:18:20
合計ジャッジ時間 3,172 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 3 ms
4,384 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0