标签:nyoj51
1 500 3 150 300 100 200 470 471
298
#include <stdio.h>
#include <string.h>
bool arr[10002];
int main(){
int n, l, m, a, b, count;
scanf("%d", &n);
while(n--){
scanf("%d%d", &l, &m);
memset(arr, 0, sizeof(arr)); //0 stands for tree
while(m--){
scanf("%d%d", &a, &b);
for(int i = a; i <= b; ++i) arr[i] = 1;
}
count = 0;
for(int i = 0; i <= l; ++i)
if(!arr[i]) ++count;
printf("%d\n", count);
}
return 0;
}
标签:nyoj51
原文地址:http://blog.csdn.net/chang_mu/article/details/30260017