cf 261B.Maxim and Restaurant
Posted ws_ccd
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了cf 261B.Maxim and Restaurant相关的知识,希望对你有一定的参考价值。
什么什么期望的,不会!
(题解http://blog.sina.com.cn/s/blog_140e100580102wj4e.html(看不懂))
#include<bits/stdc++.h> #define LL long long #define LD long double #define N 100005 using namespace std; inline int ra() { int x=0,f=1; char ch=getchar(); while (ch<‘0‘ || ch>‘9‘) {if (ch==‘-‘) f=-1; ch=getchar();} while (ch>=‘0‘ && ch<=‘9‘) {x=x*10+ch-‘0‘; ch=getchar();} return x*f; } LD C[55]; LD dp[55][55][105]; int a[55]; int main() { int n=ra(); C[0]=1; for (int i=1; i<=n; i++) { C[i]=C[i-1]*(LD)i; a[i]=ra(); } sort(a+1,a+n+1); int m=ra(); dp[1][0][0]=1; dp[1][1][a[1]]=1; for (int i=1; i<=n; i++) for (int j=0; j<=i; j++) for (int k=0; k<=m; k++) { dp[i+1][j+1][k+a[i+1]]+=dp[i][j][k]; dp[i+1][j][k]+=dp[i][j][k]; } LD res=0; for (int j=1; j<=n; j++) for (int k=0; k<=m; k++) { res+=dp[n][j][k]*(C[j]*C[n-j]); cout<<j<<" "<<k<<" "<<dp[n][j][k]<<endl; } res=res/C[n]; cout<<res; return 0; }
以上是关于cf 261B.Maxim and Restaurant的主要内容,如果未能解决你的问题,请参考以下文章
CF #261 div2 D. Pashmak and Parmida's problem (树状数组版)
CodeForces - 261B Maxim and Restaurant
Codeforces 854 B Maxim Buys an Apartment 思维 水题
codeforces 261B Maxim and Restaurant(概率DP)