- 校门外的树
- 2015-09-12 15:28:24 @
#include <stdio.h>
#include <string.h>
void cutdownTree(char *trees,int Start,int End)
{
for (int i=Start;i<=End;i++)
trees[i]=0;
}
int countTree(char *trees,int L)
{
int count = 0;
for(int i=0;i<L;i++)
if(trees[i])
count++;
return count;
}
int main()
{
int L,M;
char *trees;
scanf("%d %d",&L,&M);
trees = new char[L+1];
memset(trees,1,L+1);
for (int i=0;i<M;i++)
{
int s,e;
scanf("%d %d",&s,&e);
if (s<e && e<=L+1)
cutdownTree(trees,s,e);
}
int result = countTree(trees,L+1);
printf("%d",result);
}
0 条评论
目前还没有评论...