求助大佬,为啥扣了十分

P1047 [NOIP2005 普及组] 校门外的树

R863931863 @ 2024-11-10 22:23:43

include <stdio.h>

include <string.h>

int main() { int l,m,n,begin,end; scanf("%d",&l); scanf("%d",&m); n=l+1; int a[n]; for (int i=0;i<n;i++) a[i]=0; while (m>0) { scanf("%d",&begin); scanf("%d",&end); for (int i=begin-1;i<end;i++) { a[i]=a[i]+1; } m-=1; } int count=0; for (int i=0;i<n;i++) { if (a[i]==0) count++; } printf("%d",count); return 0; }


by kkxy @ 2024-11-14 18:35:31

#include<stdio.h>
int L,m,j,a[2],b[10001],count=0,i;
int main()
{

    scanf("%d%d",&L,&m);
    for(i=0;i<m;i++)
    {
        for(j=0;j<2;j++)
        scanf("%d",&a[j]);
        for(j=0;j<=L;j++)
        if(j>=a[0]&&j<=a[1])
        b[j]=1;
    }
    for(i=0;i<=L;i++){
        if(b[i]!=1)
        count++;
    }
    printf("%d",count);
}

这样


by kkxy @ 2024-11-14 18:36:56

求关注


|