描述 Tom goes to Dragon's nest and wants to get Dragon's treasures. Dragon says: "I put my treasures in 'N' boxes. For each treasure box 'i', it has the probability of 'pi' to explode when you open it. You can take all the treasures you get." But Dragon doesn't know that the prophet tells Tom that if the sum of the explosion probabilities of all the treasure boxes he opens doesn't exceed 'P', he can survive. Tom wants to know how many treasures he can get. 输入 The first line of input gives T (0<T<=100), the number of test cases. For each test case, the first line gives a floating point number P (0.0<=P<=1.0), the sum of the explosion probabilities of all the treasure boxes Tom opens cannot exceed, and an integer N (0<N<=100), the number of boxes Dragon gives to Tom. Then follow N lines, where line i gives an integer Mi (0<Mi<=100) and a floating point number pi (0.0<=pi<=1.0), representing that box i contains Mi treasures, and its explosion probability is pi. 输出
时间: 2023-06-18 19:04:15 浏览: 102
对于每个测试用例,输出一行,包含一个整数,表示Tom最多可以获得的宝藏数量。
示例输入:
2
0.5 3
1 0.2
2 0.3
3 0.5
0.2 2
2 0.1
3 0.2
示例输出:
5
2
解释:
对于第一组测试用例,Tom可以打开第1、2、3个宝箱,他的总爆炸概率是0.2+0.3+0.5=1.0,与P=0.5相比,超过了限制。所以他只能打开前两个宝箱,获得1+2=3个宝藏,这是最多的。
对于第二组测试用例,Tom可以打开任意一个宝箱,总爆炸概率都不会超过0.2,所以他可以打开任何一个宝箱,获得2或3个宝藏,最多是2个。
相关问题
Uncaught SyntaxError: Unexpected token '<' (at canvas-nest.js:1:1)
这个错误通常表示在canvas-nest.js文件的第一行有一个不期望出现的字符"<"。这可能是由于以下几种原因导致的:
1. 文件路径错误:请确保引入canvas-nest.js文件的路径是正确的,并且文件存在于指定的位置。
2. 文件内容错误:打开canvas-nest.js文件,检查第一行是否存在非法字符"<"。如果是这种情况,可能是文件下载或复制时出现了问题。您可以尝试重新下载或复制文件。
3. 引入顺序错误:如果您在页面中同时引入了多个JavaScript文件,请确保引入的顺序是正确的。某些脚本可能依赖于其他脚本,引入顺序错误可能导致脚本执行错误。
请您检查以上几点,并尝试修复问题。如果问题仍然存在,请提供更多相关信息,以便我能够更准确地帮助您解决问题。
nest exception is java.sql.SQLException:ORA-01476:除数为0
这个错误提示是说在执行SQL语句时,除数为0了,Oracle数据库不允许除数为0。你可以检查一下执行的SQL语句,看看是不是有除法运算,然后检查一下这个除数是否可能为0,如果是,需要在SQL语句中加上判断语句,避免除数为0的情况发生。如果不是,那么可能是数据出现了异常,需要进一步调查。另外,如果你是在Java代码中执行SQL语句,可以在代码中添加异常处理,处理这个SQLException,在程序运行时打印出具体的错误信息,方便定位问题。