POJ-2665

来源:互联网 发布:如何在mac上切换中英文 编辑:程序博客网 时间:2024/05/29 12:16

题目分析:

求解移走划定区域树木后,剩下树木的个数。


解题思路:

没什么特别的地方。


解题代码:

#include<iostream>using namespace std;int main(int argc, char *argv[]){int L,M;while(cin>>L>>M,L||M){int treeLeft=L+1;for(int i=0;i<M;i++){int start;int end;cin>>start>>end;treeLeft-=(end-start+1);}cout<<treeLeft<<endl;}return 0;}


0 0
原创粉丝点击