# 求助!!为什么30分!!!

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

mihoyo123456 @ 2023-08-22 13:24:08


#include <stdio.h>
int main()
{
    int L,M,i,u,v,c,count = 0;
    scanf("%d %d",&L,&M);
    int a[L];
    for(i = 0;i <= L;i++)
    {
        a[i] = 1;
     } 
    for(c = 0;c < M;c++)
    {
        scanf("%d %d",&u,&v);
        for(i = u;i <= v;i++)
        {
            a[i] = 0;
        }
    }
    for(i = 0;i <= L;i++)
    {
        if(a[i] == 1)
        {
            count++;
        }
    }
    printf("%d",count);
    return 0;
 } 

by KidzzZip @ 2023-08-22 13:43:26

int a[l]改成int a[10001]


by __yun__ @ 2023-08-22 13:58:24

@mihoyo123456 OI届基本常识:数组要开全局的,不能按照输入开。


|