北京师范大学珠海分校
Judge Online of ACM ICPC
1268 种树问题
C语言版
Judge Online of ACM ICPC
1268 种树问题
C语言版
- #include <stdio.h>
- int main(){
- int l=0,n,i,j,a[101],x,y,sum;
- while(1){
- sum=0;
- scanf("%d",&l);
- if (l==-1) break;
- for (i=0;i<=l;i++) a[i]=0;
- scanf("%d",&n);
- for (i=1;i<=n;i++){
- scanf("%d%d",&x,&y);
- for (j=x;j<=y;j++) a[j]=1;
- }
- for (i=0;i<=l;i++) if (a[i]==0) sum++;
- printf("%d/n",sum);
- }
- return 0;
- }