[Codeforces-div.1 167B] Wizards and Huge Prize
[Codeforces-div.1 167B] Wizards and Huge Prize

试题分析
注意到每个物品互相独立,互不干扰之后就非常好做了。
算出一个物品最后的价值期望,然后乘以K即可。
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define LL long long
inline int read(){
int x=0,f=1; char c=getchar();
for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
for(;isdigit(c);c=getchar()) x=x*10+c-'0';
return x*f;
}
const int INF = 2147483600;
const int MAXN = 100010;
int N,K; double f[2][MAXN+1];
int main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
N=read(),K=read();
//for(int j=1;j<=N+1;j++) f[N&1][j]=0;
for(int i=N-1;i>=0;i--){
int x=(i&1),y=(x^1);
//for(int j=1;j<=N;j++) f[x][j]=0;
for(int j=1;j<800;j++)
f[x][j]=(f[y][j+1]+j)/(1.0*K*(j+1))+
1.0*j*(f[y][j]+(1.0*(j+1)/2.0))/(1.0*K*(j+1))+
(1.0-(1.0/(1.0*K)))*f[y][j];
} //cout<<f[0][1]<<endl;
printf("%.9lf",1.0*K*f[0][1]);
return 0;
}
[Codeforces-div.1 167B] Wizards and Huge Prize的更多相关文章
- Codeforces Round #114 (Div. 1) B. Wizards and Huge Prize 概率dp
B. Wizards and Huge Prize Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...
- Codeforces 167B Wizards and Huge Prize(概率dp)
题意: n个人,开始有一个容量为k得背包,击败一个人背包可以获得一定容量或得到一个财富(放入背包内),给出击败每个人的概率,求至少击败l个人,且背包容量大于获得的总财富值的概率 分析: 状态好确定,d ...
- CodeForces 167B - Wizards and Huge Prize 期望概率dp
初步分析:把赢了的巡回赛的a值加起来就是最后的剩余空间 这个明显的是状态转移的dp啊,然而他的状态比较骚是个数组,表示剩余空间,f(i,j,b),i表示比到第几场,j表示赢了几场,b就是里面的核心状态 ...
- [codeforces167B]Wizards and Huge Prize
B. Wizards and Huge Prize time limit per test: 2 seconds memory limit per test: 256 megabytes input: ...
- Codeforces Round #114 (Div. 1) A. Wizards and Trolleybuses 物理题
A. Wizards and Trolleybuses Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/conte ...
- Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题
A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...
- Codeforces Round #114 (Div. 1) D. Wizards and Roads 笛卡尔树+树贪心+阅读题
D. Wizards and Roads 题目连接: http://www.codeforces.com/contest/167/problem/D Description In some count ...
- Codeforces Round #114 (Div. 1) E. Wizards and Bets 高斯消元
E. Wizards and Bets 题目连接: http://www.codeforces.com/contest/167/problem/E Description In some countr ...
- Codeforces Round #114 (Div. 1) C. Wizards and Numbers 博弈论
C. Wizards and Numbers 题目连接: http://codeforces.com/problemset/problem/167/C Description In some coun ...
随机推荐
- 代理设计模式iOS开发Demo(示例程序)源代码
iOS程序源代码下载链接:03-代理设计模式.zip28.3 KB // main.m // // main.m // 03-代理设计模式 // // Created by apple ...
- Python3 json、pickle序列化与反序列化
注意:可以dumps多次,loads只能一次,一般我们只dumps一次,loads一次,多个版本就写入多个文件 一.json序列化与反序列化: 支持各种语言数据交互,但只能处理字典,列表,集合等简单的 ...
- 在Linux中使用C语言实现控制流保护(CFG)【转】
转自:http://www.codesec.net/view/537311.html 一.前言 最近版本的windows有一个新的缓解措施叫做控制流保护(CFG).在一个非直接调用之前――例如,函数指 ...
- java===java基础学习(2)---运算符,三元操作符,数学函数
主要介绍运算符,和数学函数以及三元运算符: package testbotoo; public class test1 { public static void main(String[] args) ...
- 【COGS2622】后缀平衡树
这是个后缀平衡树的裸题.... 然后傻逼的我调了一下午. #include<bits/stdc++.h> typedef long long ll; using namespace std ...
- hadoop-Rpc使用实例
代码:https://github.com/xufeng79x/hadoop-common-rpc-demo 1. 简介 hadoop中使用rpc机制来进行分布式进程间的通信,被封装进了hadoop- ...
- mysql 安装和配置
mysql 安装: 在命令行输入 sudo apt-get install mysql-server 安装过程中会跳出来一个窗口,输入数据库root用户的密码(必须输入密码) 安装完成后 通过 my ...
- vsftpd 虚拟用户配置
vsftpd 虚拟用户的作用是 通过不同的虚拟用户可以有不同的根目录. 从 2.3.5 版本之后,vsftpd增强了安全检查,如果用户被限定在了其主目录下,则该用户的主目录不能在具有写权限了,如果检查 ...
- JQUERY 提取多个元素 a img 的 src href
<div class="abc"><a href="1.html"><img src="1.jpg"/> ...
- Centos7 环境准备
Centos7 环境准备 #关闭防火墙 systemctl stop firewalld systemctl disable firewalld #关闭selinux sed -i 's/SELINU ...