1个回答
展开全部
最简单,最暴力的解法:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
int L, n;
int i, left, right;
bool tree[100010] = { false };
scanf("%d%d", &L, &n);
for (i = 0; i < n; ++i){
scanf("%d%d", &left, &right);
for (int j = left; j <= right; ++j){
tree[j] = true;
}
}
int cnt = 0;
for (i = 0; i <= L; ++i){
if (!tree[i])cnt++;
}
printf("%d\n", cnt);
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询