bbggxggg @ 2022-12-11 13:25:17
#include<bits/stdc++.h>
using namespace std;
int a[100000001]={0,},u[100000001],v[100000001];
int main()
{
int m,l,i,j,head,tail,s=0;
cin>>l>>m;
for(i=1;i<=m;i++){
cin>>u[i]>>v[i];
}
for(i=1;i<=m;i++){
head=u[i];
tail=v[i];
for(j=head;j<=tail;j++){
a[j]=1;
}
}
for(i=1;i<=l;i++){
if(a[i]==0){
s++;
}
}
cout<<s+1<<endl;
return 0;
}
by Loser_Syx @ 2022-12-11 13:26:46
@bbggxggg 为什么s要+1
by Loser_Syx @ 2022-12-11 13:28:00
@bbggxggg 把i定义成0(最后一个for),s就不用+1了(输出时)