POJ 2521:How much did the businessman lose

原创 2015年07月11日 10:37:42

How much did the businessman lose
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 9965   Accepted: 6749

Description

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. 

Input

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. 

Output

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.

Sample Input

40 70 100 30
40 70 50 20
14604 32391 3902 153
0 0 0 0

Sample Output

70
20
-13885

水题,商贩花N元买了一个商品,卖M元,买的人给了商贩P元的假币,C是商贩找回给买家的真钞。

问整个过程中商贩赔了多少钱。

赔的钱=N-(M-P+C)+C=N-M+P

代码:。。。

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	int n,m,p,c;
	while(cin>>n>>m>>p>>c && n+m+p+c)
	{
		cout<<n-m+p<<endl;
	}
	return 0;
}




版权声明:本文为博主原创文章,未经博主允许不得转载。 举报

相关文章推荐

How much the cost of an APP development?

Usually, people don’t understand the process of APP development and they also feel confused. How muc...

How Did Watson Answer?

Watson是IBM公司为参加《Jeopardy!》(中文译名《危险游戏!》)而开发的QA系统。本文讲述了Watson的大概构成与工作流程。

精选:深入理解 Docker 内部原理及网络配置

网络绝对是任何系统的核心,对于容器而言也是如此。Docker 作为目前最火的轻量级容器技术,有很多令人称道的功能,如 Docker 的镜像管理。然而,Docker的网络一直以来都比较薄弱,所以我们有必要深入了解Docker的网络知识,以满足更高的网络需求。

how did this thing go

问题在哪里? 1:df -h显示的存储挂载的内容,可以看到一个物理挂载的目录比如: /dev/mapper/xxxxx 然后后面是文件系统,后面是在文件系统中的挂载点 但是如果你使...

How much memory does malloc(0) allocate?

原文:http://prog21.dadgum.com/179.html On most systems, this little C program will soak up all av...

How much training data do you need?

How much training data do you need?   转载至:https://medium.com/@malay.haldar/how-much-training-d...

How much you really want to succeed

There was a young man who you know he wanted to make a lot of money and so he went to this guru, rig...

How Did Watson Answer? —— Deep Parsing

Watson中使用了两种分析器——ESG(English Slot Grammar)和PAS(Predicate-Argument Structure)。PAS建构在ESG之上,以支持更高层的语法分析...

How Did Watson Answer —— Automatic Knowledge Acquisition

一、摘要不同于模式匹配的知识获取,Waston中可以在非结构化文本中通过简单的语义分析来自动获取知识,甚至是以前不存在于知识库中的类型。知识获取分两步——第一,抽取浅层知识,第二,统计推理语义。这套方...

How Did Watson Answer? —— About Question Analysis

Watson答题的第一步是对问题进行分析,分析器混合使用了“深度槽语法分析器”(deep Slot Grammar parser, 由于不了解这个分析器到底是什么鬼,暂时这么叫吧)、命名实体识别器、...

How Did Watson Answer? —— Textual Evidance

Waston中使用“支持证据检索”对每个候选答案进行并行的独立的查询,检索算法中综合了题干和文章中的多个要素和关系。
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)