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

建议使用的浏览器:

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

2521:How much did the businessman lose

题目描述
Businessmen, of course, can make much money. However, sometimes, they would lose money in trading. For example, Jame, a businessman, brought in some goods each cost him 40 yuan and he decided to sell at the price of 70 yuan. Then a customer came to buy one, gave Jame 100 yuan, and of course got back 30 yuan. You may said, "Jame earned 30 yuan." But unfortunately, Jame found the 100 yuan from the customer was fake. What a poor man! In this case Jame lost 70 yuan (40 (the goods price) + 30 (the money paid back to the customer)).

Now your task is to calculate how much Jame would lose in this kind of trade. Of course in this case, sometimes Jame may still earn.
输入解释
The input consists of several instances. Each instance contains four integers N, M, P and C, which are all in the range [0, 50000], separated by a single space.

N is the cost price of Jame good.
M is the sell price.
P is the total fake money the customer gave Jame.
C is how much Jame paid back to the customer.

Here N < M. And P may be less than M, as customer may pay with some fake money and some true money.

The input is terminated by a line containing 4 zeros.
输出解释
For one instance, output one line contains exactly one integer, which tells how much Jame lost in the trade. If Jame still earned, just output a negative integer, the absolute value of which tells the money Jame earned.
输入样例
40 70 100 30
40 70 50 20
14604 32391 3902 153
0 0 0 0
输出样例
70
20
-13885

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2521

最后修改于 2020-10-29T06:34:46+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536