博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2013 Asia Regional Changchun C
阅读量:7191 次
发布时间:2019-06-29

本文共 4165 字,大约阅读时间需要 13 分钟。

Little Tiger vs. Deep Monkey

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)

Total Submission(s): 960    Accepted Submission(s): 344

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

 

一开始想法是对的,但是实现起来没弄好。

用long long存种类数竟然一直wa,改成概率就AC了,应该是精度的问题,毕竟2^40太大了。

1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #define M(a,b) memset(a,b,sizeof(a)) 9 #define eps 1e-610 using namespace std;11 12 double p;13 int n;14 int num[45];15 double dp[45][40005];16 int cnt;17 18 int main()19 {20 int t;21 scanf("%d",&t);22 while(t--)23 {24 scanf("%d%lf",&n,&p);25 //long long a = pow(2,(long long)n);26 for(int i = 0;i
=0;i--)41 {42 res+=dp[n][i];43 if(res>1-p) {ans = i; break;}44 }45 printf("%d\n",ans);46 }47 return 0;48 }49 /*50 151 3 0.152 1 2 353 1054 40 0.555 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 156 1057 10 0.758 1 2 3 2 3 2 1 1 3 459 1360 61 */

 把之前wa的代码也粘上吧:

1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #define M(a,b) memset(a,b,sizeof(a)) 9 #define eps 1e-610 using namespace std;11 12 double p;13 int n;14 int num[45];15 int cnt;16 double m[400005];17 double pls[400005];18 int which[400005];19 long long a;20 21 int main()22 {23 int t;24 scanf("%d",&t);25 while(t--)26 {27 scanf("%d%lf",&n,&p);28 a = pow(2,n);29 for(int i = 0;i
0)41 {42 pls[cnt] = m[j];43 which[cnt] = j+num[i];44 cnt++;45 }46 }47 for(int i = 0;i
=p) {ans = i; break;}58 }59 //cout<
<

 

转载于:https://www.cnblogs.com/haohaooo/p/4041684.html

你可能感兴趣的文章
Robot Framework学习笔记(八)------ride标签使用
查看>>
一款简洁而强大的前端框架—JQuery
查看>>
js中的解绑事件
查看>>
ubuntu16.04下编译安装vim8.1
查看>>
DSSM 深度学习解决 NLP 问题:语义相似度计算
查看>>
真实世界的脉络].(英)戴维.多伊奇.pdf
查看>>
POJ 3710 Christmas Game
查看>>
秒懂神经网络---真·模拟退火算法
查看>>
js进阶 10-9 -of-type型子元素伪类选择器
查看>>
html5--6-14 CSS3中的颜色表示方式
查看>>
thinkphp5空控制器和空操作
查看>>
Mac下的UI自动化测试 (二)
查看>>
多线程爬虫
查看>>
bootstrap-table-master
查看>>
LeetCode 265: Paint House II
查看>>
Navicat 远程连接 Oracle11g 数据库报错 No listener 的问题
查看>>
python设计模式之单例模式
查看>>
Flex 布局教程:语法篇
查看>>
JVM内存模型和内存分配学习心得
查看>>
学术家族树典型用户的场景模拟
查看>>