这是一道acm题目,不知道为什么我的答案总是不对Problem J Time Limit :2000/1000ms (Java/Other) Memory Limit :65536/32768K (Java/Other)Total Submission(s) :185 Accepted Submission(s) :42Font:Times New Roman | Verdana | Georgia Font Siz

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/02 14:04:13

这是一道acm题目,不知道为什么我的答案总是不对Problem J Time Limit :2000/1000ms (Java/Other) Memory Limit :65536/32768K (Java/Other)Total Submission(s) :185 Accepted Submission(s) :42Font:Times New Roman | Verdana | Georgia Font Siz
这是一道acm题目,不知道为什么我的答案总是不对
Problem J
Time Limit :2000/1000ms (Java/Other) Memory Limit :65536/32768K (Java/Other)
Total Submission(s) :185 Accepted Submission(s) :42
Font:Times New Roman | Verdana | Georgia
Font Size:← →
Problem Description
FatMouse prepared M pounds of cat food,ready to trade with the cats guarding the warehouse containing his favorite food,JavaBean.
The warehouse has N rooms.The i-th room contains J[i] pounds of JavaBeans and requires F[i] pounds of cat food.FatMouse does not have to trade for all the JavaBeans in the room,instead,he may get J[i]* a% pounds of JavaBeans if he pays F[i]* a% pounds of cat food.Here a is a real number.Now he is assigning this homework to you:tell him the maximum amount of JavaBeans he can obtain.
Input
The input consists of multiple test cases.Each test case begins with a line containing two non-negative integers M and N.Then N lines follow,each contains two non-negative integers J[i] and F[i] respectively.The last test case is followed by two -1's.All integers are not greater than 1000.
Output
For each test case,print in a single line a real number accurate up to 3 decimal places,which is the maximum amount of JavaBeans that FatMouse can obtain.
Sample Input
5 3
7 2
4 3
5 2
20 3
25 18
24 15
15 10
-1 -1
Sample Output
13.333
31.500
#include
int main()
{
\x05int b[1000],p[1000],m,r,i,j,k,T,all;
\x05double n[1000],max;
\x05while(scanf("%d%d",&m,&r),=-1 && =-1)
\x05{\x05
\x05for(i=0;i

这是一道acm题目,不知道为什么我的答案总是不对Problem J Time Limit :2000/1000ms (Java/Other) Memory Limit :65536/32768K (Java/Other)Total Submission(s) :185 Accepted Submission(s) :42Font:Times New Roman | Verdana | Georgia Font Siz
#include
#include
using namespace std;
float Max(float *f,int& index,int length)
{
float max=0.0;
for(int i=0;imax)
{
max=f[i];
index=i;
}
}
return max;
}
int main()
{
int M,N,*mfood,*cfood,pos;
float *p,maxfood;
while(scanf("%d %d",&M,&N)!=EOF&&M!=-1&&N!=-1)
{
p=new float[N];
cfood=new int[N];
mfood=new int[N];
pos=0;
maxfood=0;
for(int i=0;i=cfood[pos])
{
maxfood+=mfood[pos];
M-=cfood[pos];
}
else
{
maxfood+=(M*pro);
M=0;
}
N--;
p[pos]=0.0;
}
printf("%.3f\n",maxfood);
delete []p;
delete []cfood;
delete []mfood;
}
return 0;
}

这是一道acm题目,不知道为什么我的答案总是不对Problem J Time Limit :2000/1000ms (Java/Other) Memory Limit :65536/32768K (Java/Other)Total Submission(s) :185 Accepted Submission(s) :42Font:Times New Roman | Verdana | Georgia Font Siz 一道数学题,我知道答案,但不知道为什么, 倩—晴——出头之日这是一道看字猜成语的题目,可是我不知道为什么,谁能跟我说一下原因. 一道集合题,是2010宣武一摸文数我知道答案选D 但是不知道为什么 一道电路的问题题目如下图所示下面是我的做法,我用叠加定理去做,为什么和答案的-8V不同,不知道错在哪了, 蛮简单的一道但是不知道为什么我得的是cos-2B 答案的cos2B 一道简单几何体求体积的题目我选C答案是D.不知道错在哪里,请各位指正. 一道数学题目是3;20我不清楚怎么做的,但是我知道答案,答案也是3:20 细胞内的遗传物质是DNA还是RNA?我做到一道题目,我觉得是DNA和RNA都有,但是答案只有DNA,不知道是答案错误还是我错误.请知情人士为我解答一下, 一道很简单的大一高数题目这道题的答案是等于1,但我不知道这是怎么得出来的,请高手告诉我,感激不尽啊 这是一道题目的答案 为什么植物没有系统这个结构层次这是我生物卷子上的一道题目,希望答案简洁一点, 这是一道大学高等数学题目.属于一元函数微积分里面的. 答案是:xg(x)-F(g(x))+C不知道为啥。 一个小学升初中的数学问题?题目是: 有一列真分数:1/2,1/3,2/3,1/4,2/4,3/4,1/5,. 问:第2002个分数是()?这是一道名牌小学过关考试题目,我知道答案,但是解答的思路和过程不知道,有知道的望能 一道六年级数学题,我不知道为什么这么做,请大家帮我解释!谢谢!急~快又好的有加分!一道六年级数学题,我爸给我说了过程和答案,我不知道为什么这么做,题目如下: 圆锥形容器中装有2升 这是一道集合类的题目,我知道答案,但是还是不太明白..知道的请进来看看吧,帮我分析分析为什么集合A={X/-2≤X≤5},B={X/m+1≤X≤2m-1},若B含与A中,求实数M的取值范围.答案如下:因为B={X/m+1 sat 的 一道grammar 的题目答案是E 帮忙解释一下 谢谢 我想知道ABCD 为什么都是对的 一道判断函数奇偶性的题目,为什么答案是奇函数?