結果

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

ソースコード

diff #

#include<bits/stdc++.h>
#if __has_include(<atcoder/all>)
#endif
using namespace std;
#define LL(...) ll __VA_ARGS__;lin(__VA_ARGS__)
#define fo(i,...) for(auto[i,i##stop,i##step]=for_range<ll>(0,__VA_ARGS__);i<i##stop;i+=i##step)
#define defpp template<ostream&o=cout>void pp(const auto&...a){[[maybe_unused]]const char*c="";((o<<c<<a,c=" "),...);o<<'\n';}void epp(const auto&...a){pp<cerr>(a...);}
#define entry defpp void main();void main2();}int main(){my::io();my::main();}namespace my{
namespace my{
void io(){cin.tie(nullptr)->sync_with_stdio(0);cout<<fixed<<setprecision(15);}
using dd=double;
using ll=long long;
template<class T>concept modulary=requires(T t){t.mod();};
template<class T>constexpr auto for_range(T s,T a,T b,T c=1){return array{a-s,b,(1-s*2)*c};}
void lin(auto&...a){(cin>>...>>a);}
constexpr auto pow(auto x,ll n,auto e){assert(n>=0);decltype(x)r=e;for(;n;x*=x,n>>=1)if(n&1)r*=x;return r;}
constexpr auto pow(auto x,ll n){return pow(x,n,1);}
template<class...A>using pack_back_t=tuple_element_t<sizeof...(A)-1,tuple<A...>>;
}
namespace my{
template<class V>struct vec;
template<int D,class T>struct hvec_helper{using type=vec<typename hvec_helper<D-1,T>::type>;};
template<class T>struct hvec_helper<0,T>{using type=T;};
template<int D,class T>using hvec=hvec_helper<D,T>::type;
template<class V>struct vec:vector<V>{
  using vector<V>::vector;
  ll size()const{return vector<V>::size();}
};
template<class...A>requires(sizeof...(A)>=2)vec(const A&...a)->vec<hvec<sizeof...(A)-2,pack_back_t<A...>>>;
}
namespace my{
template<class T>T fac(ll n){static vec<T>v{1};if(ll m=v.size();m<=n){v.resize(n+1);fo(i,m,n+1)v[i]=v[i-1]*i;}return v[n];}
template<class T>T comb(ll n,ll k){
  if(n<0||k<0||n<k)return 0;
  if constexpr(modulary<T>){ }
  else return fac<T>(n)/fac<T>(k)/fac<T>(n-k);
}
}
namespace my{entry
void main(){
  LL(F,N,K);

  // K番目の値を表す確率変数をXとすると,
  // E[X]=\sum_{x=1}^F p(x)*x (p(x):大きい方からK番目がxの確率)
  // E[X]=\sum_{x=1}^F q(x) (q(x):大きい方からK番目がx以上の確率=x以上がK回以上出る確率)
  dd ans=0;
  fo(x,1,F+1){
    dd qx=0;
    dd P=dd(F-(x-1))/F;
    dd Q=dd(x-1)/F;
    fo(k,K,N+1)qx+=pow(P,k)*pow(Q,N-k)*comb<dd>(N,k);
    ans+=qx;
  }
  pp(ans);
}}
0