Codeforces 601C Kleofáš and the n-thlon(dp)
来源:互联网 发布:iphone手机主题软件 编辑:程序博客网 时间:2024/05/11 06:00
题目链接:Codeforces 601C Kleofáš and the n-thlon
解题思路
dp[i][j]表示到第i场比赛时,得分为j的人数期望。dp[i][j] = sum { dp[i-1][j-x] ~ dp[i-1][j-x] | 1 ≤ x ≤ m && x != rank[i] }
代码
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 2 * 1e5 + 5;int N, M, X[105];double dp[2][maxn];int main () { scanf("%d%d", &N, &M); for (int i = 1; i <= N; i++) scanf("%d", &X[i]); if (M == 1) printf("%.10lf\n", 1.0); else { int nw = 0, nx = 1, s = 0; memset(dp[nx], 0, sizeof(dp[nx])); dp[nx][0] = M - 1; for (int i = 1; i <= N; i++) { swap(nw, nx); memset(dp[nx], 0, sizeof(dp[nx])); for (int j = 0; j <= i * M; j++) { double p = dp[nw][j] / (M-1); dp[nx][j+1] += p; dp[nx][j+M+1] -= p; dp[nx][j + X[i]] -= p; dp[nx][j + X[i] + 1] += p; } for (int j = 1; j <= (i + 1) * M; j++) dp[nx][j] += dp[nx][j-1]; s += X[i]; } double ans = 0; for (int i = 0; i < s; i++) ans += dp[nx][i]; printf("%.10lf\n", ans + 1); } return 0;}
0 0
- Codeforces 601C Kleofáš and the n-thlon(dp)
- CodeForces 601 C.Kleofáš and the n-thlon(概率DP)
- Codeforces Round #333 E. Kleofáš and the n-thlon (期望dp)
- Codeforces Round #333 (Div. 2) E. Kleofáš and the n-thlon (概率dp)
- CF 601C(Kleofáš and the n-thlon-期望dp)
- 【codeforces 602E】Kleofáš and the n-thlon
- codeforces 602 E. Kleofáš and the n-thlon (概率dp)
- 【Codeforces Round 333 (Div 2)E】【期望DP概率做法 树状数组转前缀和】Kleofáš and the n-thlon n场比赛m个人获得总名次的期望
- Codeforces 682C Alyona and the Tree DP
- Codeforces 842 C. Ilya And The Tree 树上dp
- Codeforces Round #358 (Div. 2) C Alyona and the Tree(树形DP)
- CodeForces 438 C.The Child and Polygon(dp+计算几何)
- Codeforces 842C Ilya And The Tree(树上DP+因子个数估计)
- codeforces #267 C George and Job(DP)
- Codeforces 558C Amr and Chemistry(dp)
- Codeforces 611C New Year and Domino(dp)
- CodeForces - 366C Dima and Salad (DP&01背包)
- Codeforces 643C Levels and Regions(斜率优化dp)
- timusoj 1748. The Most Complex Number (反素数&剪枝) 好题
- codeforces 604A Uncowed Forces
- 使用Java编写并运行Spark应用程序
- 织梦首页php301重定向
- TCP/IP协议 三次握手与四次挥手
- Codeforces 601C Kleofáš and the n-thlon(dp)
- webrtc(一) agc
- Visual Studio单元测试命令行方式
- byte[]数组和int之间的转换
- MySQL如何只导出指定的表结构和数据
- 《python爬虫》学习笔记:urllib2库的使用
- trunc函数的方法
- Codeforces 601D Acyclic Organic Compounds(dfs+字典树合并)
- 引用(强软弱虚)、WeakHashMap、IdentityHashMap与EnumMapJAVA132