当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

4395:D-mail

题目描述
To control the world, which is the ambition of Ryntarou Okabe, a mad scientist, is a problem that both of technology and wisdom are needed to handle it. After long time of experiment, Okabe eventually invented a strange machine, Telephone Oven, which can be used to send mails to the past! The mail is called D-mail in short. D-mail can be used to change the future of the world, but it cannot change it as what Okabe thinks exactly. According to the theory of time travel, the future of the world can be described by a real number, which is called Divergence. Now, Okabe has already calculated the Divergence that represents the world in which Okabe takes the control of the whole world. He calls it Steins Gate. There are kinds of D-mails with different content. And he has got the influence each kind of D-mail has to the Divergence. Now he wants to change the Divergence to a number as close to the Steins Gate as possible by selecting several kinds of D-mail, while each kind of D-mail cannot be used more than once. (He can choose 0 D-mail.)


But if he changes the divergence too greatly that it becomes bigger than 2 or equals 2 during the process he send D-mail, then will he be trapped in the infinity maze of time and be "corrected" by the world itself, so he should choose the best order to send the D-mail so as to keep alive before he achieves his goal. Can you help him calculate the best result he can get? The original Divergence is 0.
输入解释
The first line contains an integer T, which represents the number of test cases.
For each test, the first line contains a real number D (-1<D<2), Stains Gate and an integer N(0<N<=200 ),represents the number of the kinds of D-mails. For the next N lines, each line contains a real number (which is no lesser than -0.1 and no bigger than 2)showing the influence of this D-mail to the Divergence. (all real number in the input file are written with exactly four digits after a decimal point.)
输出解释
For each test case, print a real number which represents the number closest to Stains Gate. The number must be written with exactly four digits after a decimal point. If there are more than one answer ,please print the smaller one.
输入样例
2
0.1234 2
0.1211
0.0023
-0.1234 2
0.1211
0.0023
输出样例
0.1234
0.0000
来自杭电HDUOJ的附加信息
Recommend zhuyuanchen520

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-4395

最后修改于 2020-10-25T23:13:06+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
10000/3000MS(Java/Others) 32768/32768K(Java/Others)