500 3 150 300 100 200 470 471
#include<stdio.h>
int main()
{
int t[10001]={0},M;
int i,j,L,n=0;
int a,b;
scanf("%d%d",&L,&M);
for(i=0;i<M;i++)
{
scanf("%d%d",&a,&b);
for(j=a;j<=b;j++)
{
t[j]=1;
}
}
for(i=0;i<=L;i++)
{
if(t[i]==1)
{
n++;
}
}
printf("%d\n",L+1-n);
return 0;
}
原文:http://www.cnblogs.com/LegendLa/p/4206632.html