我們可以暴力枚舉每一個人分幾個糖果,再暴力統計答案即可

每次遞歸下去可以從1-n號人,決定選多少個糖果再遞歸

#include<bits/stdc++.h>
using namespace std;
int n,k;
double a,r,x[1000],y[1000],s;
void get(int d,double p,double ss,int c){
	if(d==n+1){
		if(c>n/2)s+=p;
		else s+=p*(a/((a+ss)));
		return;
	}
	get(d+1,p*y[d]/100.0,ss,c+1);
	get(d+1,p*(100.0-y[d])/100.0,ss+x[d],c);
}
void dfs(int x,int k){
	if(k==0){//用來剪枝
		s=0;
		get(1,1,0,0);
		r=max(r,s);
		return;
	}
	if(x==n+1)return;
	for(int i=0;i<=k;i++)
		if(y[x]+i*10<=100){
			y[x]+=i*10;
			dfs(x+1,k-i);
			y[x]-=i*10;
		}
}
int main(){
	scanf("%d%d%lf",&n,&k,&a);
	for(int i=1;i<=n;i++)
		scanf("%lf%lf",&x[i],&y[i]);
	double ans=0;
	for(int i=1;i<=n;i++)
		ans+=(100.0-y[i]);
	if(ans<=k*10){
		printf("1.000000");
		return 0;
	}
	dfs(1,k);
	printf("%.6lf",r);
}

jzoj2941的更多相关文章

随机推荐

  1. Mathtype使用技巧

    1. 打开/关闭MathType窗口 Alt+Ctrl+q:插入inline公式   Ctrl+S:更新公式到Word相应位置 Alt+F4:保存并关闭MathType窗口,返回Word. 2. 公式 ...

  2. [SoapUI] 配置默认环境的properties

    <Envs> <Env id="Live,Default environment"> <Project> <CusProperty nam ...

  3. [Selenium]如何实现上传本地文件

    public void uploadLocalFileToServer(String uploadFileName){ String AutomationPath = System.getProper ...

  4. 分组取前N记录

    分组取前N记录   经常看到问题,如何取出每组的前N条记录.方便大家参考于是便把常见的几种解法列出于下. 问题:有表 如下,要求取出各班前两名(允许并列第二)Table1+----+------+-- ...

  5. 【Maven】安装及配置(Win)

    Maven Maven是一款自动化构建的工具软件,它是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具. 检查环境 maven是基于Java的工具软件, ...

  6. 2018.09.29 bzoj3885: Cow Rectangles(悬线法+二分)

    传送门 对于第一个问题,直接用悬线法求出最大的子矩阵面积,然后对于每一个能得到最大面积的矩阵,我们用二分法去掉四周的空白部分来更新第二个答案. 代码: #include<bits/stdc++. ...

  7. 28. Bad Influence of Western Diet 西式饮食的消极影响

    28. Bad Influence of Western Diet 西式饮食的消极影响 ① The spread of Western eating habits around the world i ...

  8. Series转成list

    直接list(series)就可以的 最佳的方式是将列表转换成Python中的科学计算包numpy包的array类型,再进行加减. 1 2 3 4 import numpy as np a = np. ...

  9. PrefixHeader.pch 在工程中的使用

    1)  新建一个pch文件 2) 在 工程 Build Settings 中搜索 header  将Precompile Prefix Header 置为YES 2) 选中pch文件, 将右侧相对路径 ...

  10. The remote end hung up unexpectedly

    fatal: The remote end hung up unexpectedly 上传一份代码的时候,出现了这个错误,然后就没有成功上传. 背景操作 主要是进行svn转换到git时候出错的,转换的 ...