砍树,POJ(2665)

题目链接:http://poj.org/problem?id=2665

解题报告: 这里的区域没有重复,若有重复的话,模拟即可。

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#define maxn 2000+10

using namespace std;
int main()
{
    long long m,n,st,ed;
    while(cin>>m>>n&&(m&&n))
    {
        while(n--)
        {
            cin>>st>>ed;
            m=m-(ed-st)-1;
        }
        cout<<m+1<<endl;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/TreeDream/p/5401733.html