The Solution of UESTC 2016 Summer Training #1 Div.2 Problem C

Link

http://acm.hust.edu.cn/vjudge/contest/121539#problem/C

Description

standard input/output 

After a long ACM training day, Master Hasan invited his trainees for a light dinner in the cafeteria. The cafeteria has N tables, each with a number of chairs around it. Before accepting the trainees into the cafeteria, Master Hasan wants to know how many unused chairs are there in the cafeteria. If there isn't enough chairs, he might invite them to a well-known Indian restaurant.

Input

The first line of input contains a single integer N(1 ≤ N ≤ 100), the number of tables in the cafeteria.

Each of the following N lines contains two integers describing a table, A and B(1 ≤ A ≤ B ≤ 100), where A represents the number of used chairs, and B represents the total number of chairs around that table.

Output

Print the number of unused chairs in the cafeteria.

Sample Input

Input
3
1 3
4 4
5 8
Output
5
Solution
This problem is a piece of cake.The number of unused chair of each table is B-A,and our task is to sum them up.
C++ Code

#include<iostream>
using namespace std;
int main()
{
  int n,a,b,sum;
  cin>>n;sum=0;
  while(n--)
  {
    cin>>a>>b;
    sum+=b-a;
  }
  cout<<sum<<endl;
  return 0;
}

转载于:https://www.cnblogs.com/cs-lyj1997/p/5712968.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值