poj 2665 Trees

//给出一段距离,即是树木的总数,然后再给出几个树木需要砍伐或者移走的区域,求剩下的树木数!注意:
//That's to say that there used to be 301 trees on the road. Now the section from 100m to 200m 
//is assigned for subway station, so 101 trees need to be moved away and only 200 trees are left. 
#include <iostream>
using namespace std;


int main()
{
    int l, m, i, s1, s2, ans, tmp;
    while (cin >> l >> m){
          if (l == 0 && m == 0)  break;
          ans = 0; 
          for (i = 0; i < m; i++){ 
              cin >> s1 >> s2;
              tmp = s2 - s1;
              ans += tmp + 1; 
          } 
          ans = l + 1 - ans;
          cout << ans << endl; 
    } 
    system("pause"); 
} 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值