fnfyu @ 2023-09-14 12:27:41
#include <stdio.h>
int main()
{
int l, m, u, v, i, j, sum=0;
scanf("%d%d", &l, &m);
int arr[10000] = { 0 };
for (i = 0; i <= l; i++)
{
arr[i] = 1;
}
while (m)
{
scanf("%d%d", &u, &v);
for (j = u - 1; j < v; j++)
{
if (arr[j])
{
arr[j] = 0;
}
}
m--;
}
for (i = 0; i <= l; i++)
{
sum += arr[i];
}
printf("%d", sum);
return 0;
}
求大佬告知
by xuchuhan @ 2023-09-14 12:40:51
@fnfyu 修改时 for
的范围是:
for (j = u; j <= v; j++)
by fnfyu @ 2023-09-14 19:27:29
@xuchuhan @xuchuhan ok 我试试
by fnfyu @ 2023-09-14 19:28:53
@xuchuhan 谢谢大佬 解决了