originalheart @ 2023-01-18 20:32:07
#include <stdio.h>
int main()
{
int a[10010]={0};
int l,m,i=0,j=0,count=0;
int u[10010]={0},v[10010]={0};
scanf("%d%d",&l,&m);
for(i=0;i<=l;i++)
{
a[i]=2;
}
for(j=0;j<m;j++)
{
scanf("%d %d",&u[j],&v[j]);
for(i=u[j];i<=v[j];i++)
{
if(a[i]!=0)
{
a[i]=0;
count++;
}
}
}
printf("%d",501-count);
return 0;
}
by isJason @ 2023-01-18 20:39:09
for(i=0;i<=l;i++){
a[i]=2;
}
printf("%d",501-count);
这两段错了吧(?
by isJason @ 2023-01-18 20:40:22
准确的说,是
printf("%d",501-count);
错了,第一段并没有错
by isJason @ 2023-01-18 20:41:28
马路上的树并不总是501颗,501应改为l+1
by isJason @ 2023-01-18 20:43:23
@originalheart
by originalheart @ 2023-01-20 18:34:53
@isJason 谢谢