HDU4815
Little Tiger vs. Deep Monkey
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 1587 Accepted Submission(s): 566
“Are you surprised by the STS (speech to speech) technology of Microsoft Research and the cat face recognition project of Google and academia? Are you curious about what technology is behind those fantastic demos?” asks the director of the Deep Lab. “Deep learning, deep learning!” Little Tiger raises his hand briskly. “Yes, clever boy, that’s deep learning (深度学习/深度神经网络)”, says the director. “However, they are only ‘a piece of cake’. I won’t tell you a top secret that our lab has invented a Deep Monkey (深猴) with more advanced technology. And that guy is as smart as human!”
“Nani ?!” Little Tiger doubts about that as he is the smartest kid in his kindergarten; even so, he is not as smart as human, “how can a monkey be smarter than me? I will challenge him.”
To verify their research achievement, the researchers of the Deep Lab are going to host an intelligence test for Little Tiger and Deep Monkey.
The test is composed of N binary choice questions. And different questions may have different scores according to their difficulties. One can get the corresponding score for a question if he chooses the correct answer; otherwise, he gets nothing. The overall score is counted as the sum of scores one gets from each question. The one with a larger overall score wins; tie happens when they get the same score.
Little Tiger assumes that Deep Monkey will choose the answer randomly as he doesn’t believe the monkey is smart. Now, Little Tiger is wondering “what score should I get at least so that I will not lose in the contest with probability of at least P? ”. As little tiger is a really smart guy, he can evaluate the answer quickly.
You, Deep Monkey, can you work it out? Show your power!
Each test case is composed of two lines. The first line has two numbers N and P separated by a blank. N is an integer, satisfying 1 ≤ N ≤ 40. P is a floating number with at most 3 digits after the decimal point, and is in the range of [0, 1]. The second line has N numbers separated by blanks, which are the scores of each question. The score of each questions is an integer and in the range of [1, 1000]
3 0.5
1 2 3

#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
#define ll long long
#define _cle(m, a) memset(m, a, sizeof(m))
#define repu(i, a, b) for(int i = a; i < b; i++)
#define repd(i, a, b) for(int i = b; i >= a; i--)
#define sfi(n) scanf("%d", &n)
#define pfi(n) printf("%d\n", n)
#define pfl(n) printf("%I64d\n", n)
#define MAXN 600000 ll d[MAXN];
ll sum;
int s[];
int n;
double p;
double mm[];
void get_m()
{
mm[] = 1.0;
repu(i, , ) mm[i] = 2.0 * mm[i - ];
return ;
} void dp()
{
memset(d, , sizeof(d));
d[] = ;
for(int i = ; i <= n; i++)
for(int j = sum; j >= s[i]; j--)
d[j] = d[j]+d[j-s[i]];
return ;
} int main()
{
int T;
sfi(T);
get_m();
while(T--)
{
sfi(n);
scanf("%lf", &p);
sum = ;
repu(i, , n + ) { sfi(s[i]); sum += s[i];}
dp(); double num = 0.0;
double monkey = (p * mm[n]);
for(ll i = ; i <= sum; i++)
{
num += d[i];
if(num >= monkey)
{
printf("%I64d\n", i);
break;
}
}
}
return ;
}
HDU4815的更多相关文章
- HDU4815/计数DP
题目链接[http://acm.hdu.edu.cn/showproblem.php?pid=4815] 简单说一下题意: 有n道题,每到题答对得分为a[ i ],假如A不输给B的最小概率是P,那么A ...
- hdu4815 概率问题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4815 好久没写dp了..最开始题意都理解错了, 哎!!我现在很饿也很困!! AC代码: #includ ...
- HDU4815 Little Tiger vs. Deep Monkey——0-1背包
题目描述 对于n道题目,每道题目有一个分值,答对加分,答错不得分,你要和一个叫深猴的比赛,题目你可以假设成判断题(不是对就是错),深猴对于所有的题目都是随机选择一个答案,而你是有脑子的,求为了不输掉比 ...
- 2013 年 acm 长春现场赛
A - Hard Code Hdu 4813 题目大意:给你一坨字符串,让你输出其栅栏密码的解码形式 思路:水题模拟 #include<iostream> #include<cstd ...
随机推荐
- 问题: unrecognized selector sent to class 0x10affab20
今天遇到了一个问题, 害我足足找了半个小时 问题: 明明可以跳进 方法 的实现里面, 但是程序运行的时候, 就是报错: 发送一个未识别消息, 而且程序直接跳出, 停止执行 原因: 项目的编译文件列表里 ...
- 利用JDK的中Proxy动态代理实现Spring的AOP技术
首先给出设计模式静态代理与动态代理的学习: http://layznet.iteye.com/blog/1182924 讲的不错 然后我们实现AOP 就要求我们对委托的所有方法的调用实现拦截 代理 ...
- Scrum Meeting---Eleven(2015-11-6)
今日已完成任务和明日要做的任务 姓名 今日已完成任务 今日时间 明日计划完成任务 估计用时 董元财 倒计时设计 3h 商品发布页设计 4h 胡亚坤 低栏设计 2h UI风格 2h 刘猛 通讯录设计 2 ...
- sqlcmd 登录和执行语句。
sqlcmd -U sa -P atc@2014 -S HK-DB01 -d msdb -Q "exec sp_start_job @job_name='3PL_OUT_TEST'" ...
- THE SENSE OF BEAUTY
#include<stdio.h> int main() { ][] = { " ,.:;j", " ,: i. .,:;ff", " : ...
- VB6.0
1. 安装包来自 http://msdn.itellyou.cn/ 下载的文件为: sc_vb6_ent_cd1.iso sc_vb6_ent_cd2.iso 2.安装时,"请输入产品的 I ...
- Mysql 命令行工具
1.Mysql命令行工具分为两类:服务端命令行工具和客户端命令行工具. 2.服务端工具 mysql_install_db:建库工具 mysqld_safe:Mysql服务的启动工具,mysqld_sa ...
- JavaSE复习_1 Java的基本格式和运算符
△.代表在当前目录.classpath能在任何路径下访问类文件. △单行注释可以嵌套,多行注释不能嵌套 △java中的标识符只能有数字,字母,$和_,其他的符号都是错误的,不合法的.其中数字不能是开头 ...
- Microsoft VS 2008 过期解决方法
开始>控制面板>添加或删除程序 里找到VS2008,点“更改/删除”,出现: 然后,打开“显示Visual Studio试用版序列号输入框小程序”的软件(单击链接可以转到下载地址),显示: ...
- 静态库冲突的解决办法:duplicate symbol
昨天在做微信sdk和xmpp的集成,发现各自单独集成没问题,一起集成却总报错,百度了好一会儿才知道,这应该是库冲突造成的问题 然后参考了很多文章,跟着敲敲一遍,却发现问题多多,最后主要综合结合了这两个 ...