2013 ACMICPC Asia Regional 长春 problem C
2015-09-23 16:38
218 查看
长春区域赛的第二简单的题,类似于01背包。
有N个判断题,每个题有个分值,有个sb随机地做,某题对了就得分,不对不得分。再给你一个P值,问:what score should I get at least so that I will not lose in the contest with probability of at least P?(至少以p的概率不输,要得多少分)
我直接用概率dp了,虽然也1A了,但是由于害怕精度损失,交的时候还心惊胆战,后来看了别人的博客,直接用次数dp,最后再一起算那样比较简单,不过总体思想还是一样的。
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 1593 Accepted Submission(s): 570
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!
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]
Output
For each test case, output only a single line with the answer.
Sample Input
Sample Output
Source
2013 Asia Regional Changchun
有N个判断题,每个题有个分值,有个sb随机地做,某题对了就得分,不对不得分。再给你一个P值,问:what score should I get at least so that I will not lose in the contest with probability of at least P?(至少以p的概率不输,要得多少分)
我直接用概率dp了,虽然也1A了,但是由于害怕精度损失,交的时候还心惊胆战,后来看了别人的博客,直接用次数dp,最后再一起算那样比较简单,不过总体思想还是一样的。
Little Tiger vs. Deep Monkey
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1593 Accepted Submission(s): 570
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!
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]
Output
For each test case, output only a single line with the answer.
Sample Input
1 3 0.5 1 2 3
Sample Output
3
Source
2013 Asia Regional Changchun
#include <iostream> #include <stdio.h> #include <math.h> #include <stdlib.h> #include <string> #include <string.h> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <stack> using namespace std; typedef long long LL; const int INF=0x7fffffff; const int MAX_N=10000; int T,N,sum; double p,lose; double score[41009]; double newscore[41009]; int s[50]; int main(){ cin>>T; while(T--){ sum=0; memset(score,0,sizeof(score)); memset(newscore,0,sizeof(newscore)); scanf("%d%lf",&N,&p); lose=1.0-p; for(int i=0;i<N;i++){ scanf("%d",&s[i]); sum+=s[i]; } score[0]=0.5; score[s[0]]=0.5; for(int i=1;i<N;i++){ for(int j=0;j<=sum;j++){ if(score[j]!=0){ double add=score[j]*0.5; newscore[j]+=add; newscore[j+s[i]]+=add; } } memcpy(score,newscore,sizeof(newscore)); memset(newscore,0,sizeof(newscore)); } double g=1; int ans=0; for(int i=sum;i>=0;i--){ g-=score[i]; if(g<p){ ans=i; break; } } printf("%d\n",ans); } return 0; }
相关文章推荐
- Android.mk文件编写规则
- HDU 5438 --Ponds【拓扑排序 && DFS】
- 翻译-精通python设计模式-工厂模式
- Visual Sudio 2012转换界面风格
- 利用HTML5云存储实现模拟对比投票效果
- 翻译-精通python设计模式-工厂模式
- 格子游戏 解题报告
- Struts2对于国际化(i18n)的支持
- JAVA问题总结之27--创建100个文件
- google drive
- Spring单例模式与线程安全
- 第四十五天 百度地图定位SDK
- leetcode Integer to Roman
- servlet单实例多线程机制
- 正则表达式
- 原创:Spring整合junit测试框架(简易教程 基于myeclipse,不需要麻烦的导包)
- 右键全屏as3
- ACCESS中如何比较日期和时间,使用DateDiff函数
- MTOM with JAX-WS Services
- 无法使用密钥激活Parallels Desktop 9 for Mac