博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
The Solution of UESTC 2016 Summer Training #1 Div.2 Problem C
阅读量:5282 次
发布时间:2019-06-14

本文共 1249 字,大约阅读时间需要 4 分钟。

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

你可能感兴趣的文章
Git 远程仓库
查看>>
HttpClient的巨坑
查看>>
关于静态文本框透明度的问题
查看>>
海量数据、高并发的优化方案
查看>>
javascript的发展及个人笔记
查看>>
全选,反全选,反选,获取选中的值,根据子选择控制全选按钮
查看>>
梦断代码读后感01
查看>>
[CF#250 Div.2 D]The Child and Zoo(并查集)
查看>>
博客园博客插入公式
查看>>
hdu 1028 Ignatius and the Princess III(母函数入门+模板)
查看>>
Ubuntu下配置安装telnet server
查看>>
Codeforces 235 E Number Challenge
查看>>
ubuntu 常见命令整理
查看>>
EJBCA安装教程+postgresql+wildfly10
查看>>
(五十四)涂鸦的实现和截图的保存
查看>>
配置EditPlus使其可以编译运行java程序
查看>>
java中的占位符\t\n\r\f
查看>>
7.14
查看>>
SDN2017 第一次作业
查看>>
MySQL通过frm 和 ibd 恢复数据过程
查看>>