题解:UVA12725 Fat and Orial
UVA12725
题目大意
小明已经考了 场考试,这 场考试他的平均分为 ;他希望再考 场考试,希望这 场考试的平均分为 ,求他在接下来 场考试中的平均分。(,)
输入有多组数据。
解题思路
根据题意,小明前 场考试的总分为
若想要总的均分为 ,则所有考试的总分为
所以后 场考试的总分为
因此后 场考试的均分为
即为所求。
值得注意的是,如果 ,需要输出 Impossible。
代码
#include<cstdio>
double n,m,a,b,ans;
int T,t;
int main()
{
scanf("%d",&T);
while (T--)
{
scanf("%lf%lf%lf%lf",&n,&m,&a,&b);
ans=(double)(m*(a+b)-n*a)/b;
if (ans>10||ans<0) printf("Case #%d: Impossible\n",++t);
else printf("Case #%d: %.2lf\n",++t,ans);
}
return 0;
}注释就不放了,前面都说得很清楚了。
题解:UVA12725 Fat and Orial
https://pvbelln.github.io/2025/07/05/sol-uva12725/