hdu 4815 Little Tiger vs. Deep Monkey
来源:互联网 发布:为什么淘宝代付不了 编辑:程序博客网 时间:2024/05/16 12:16
Little Tiger vs. Deep Monkey
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1157 Accepted Submission(s): 408
Problem Description
A crowd of little animals is visiting a mysterious laboratory – The Deep Lab of SYSU.
“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!
“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!
Input
The first line of input contains a single integer T (1 ≤ T ≤ 10) indicating the number of test cases. Then T test cases follow.
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]
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]
Output
For each test case, output only a single line with the answer.
Sample Input
13 0.51 2 3
Sample Output
3
Source
2013 Asia Regional Changchun
题意:每道题B答对的概率都是50%,然后给你n道题,每道题一个分数,让你求A至少得多少分,使其不输给B的概率至少>=P。
做法:概率dp,状态转移方程dp[i][j]代表回答i题得到分数为j的概率,状态转移方程见代码。
#include <iostream>#include <cstdio>#include <climits>#include <cstring>#include <cstdlib>#include <cmath>#include <vector>#include <queue>#include <map>#include<stack>#include <set>#include <algorithm>#include<ctime>#define esp 1e-6#define LL long long#define inf 0x0f0f0f0fusing namespace std;double dp[45][45000];int main(){ int t; int n,i,j,ans,mx,sum; int num[1005]; double p; scanf("%d",&t); while(t--) { sum=0; ans=0; memset(dp,0,sizeof(dp)); memset(num,0,sizeof(num)); scanf("%d%lf",&n,&p); for(i=1;i<=n;i++) { scanf("%d",&num[i]); sum+=num[i]; } mx=n*1000; dp[0][0]=1; for(i=0;i<n;i++) for(j=0;j<=mx;j++) { if(dp[i][j]>0) { dp[i+1][j+num[i+1]]+=dp[i][j]*0.5; dp[i+1][j]+=dp[i][j]*0.5; } } double tt; tt=0; for(i=0;i<=sum;i++) { tt+=dp[n][i]; if(tt>=p) { ans=i; break; } } printf("%d\n",ans); }}
0 0
- HDU 4815 Little Tiger vs. Deep Monkey
- hdu 4815 Little Tiger vs. Deep Monkey
- hdu 4815 Little Tiger vs. Deep Monkey
- HDU - 4815 Little Tiger vs. Deep Monkey
- HDU 4815 Little Tiger vs. Deep Monkey
- Little Tiger vs. Deep Monkey HDU
- hdu 4815 Little Tiger vs. Deep Monkey 概率dp
- hdu 4815 Little Tiger vs. Deep Monkey (背包+思维)
- [hdu 4815]Little Tiger vs. Deep Monkey 01背包
- HDU 4815——Little Tiger vs. Deep Monkey
- HDU 4815 Little Tiger vs. Deep Monkey 背包问题
- HDU 4815 Little Tiger vs. Deep Monkey 01背包
- hdu 4815 Little Tiger vs. Deep Monkey(数学+dp)
- 【HDU】4815 - Little Tiger vs. Deep Monkey(母函数)
- HDU 4815 Little Tiger vs. Deep Monkey(母函数)
- -----hdu 4815 -01背包- Little Tiger vs. Deep Monkey
- HDOJ 4815 Little Tiger vs. Deep Monkey
- Little Tiger vs. Deep Monkey
- Andrid listview异步图片加载之优化篇
- 内核模块编程一
- Maven环境搭建
- spring security源码分析_HttpSessionEventPublisher
- 软件工程第二次作业--经典游戏改编!!!
- hdu 4815 Little Tiger vs. Deep Monkey
- 使用Flash Builder“Burrito”和Flex SDK“Hero”创建Android移动应用程序
- openwrt开发之用户程序打包
- Android自定义spinner下拉框实现的实现
- NET中那些所谓的新语法之三:系统预定义委托与Lambda表达式
- 浅绛彩瓷的行情与收藏
- Xcode 6 AutoLayout Size Classes
- wamp手动搭建
- 但更热好热好热好热呵