tankewei911 @ 2023-07-12 09:01:41
#include<bits/stdc++.h>
using namespace std;
long long b[10005];
int main(){
long long a,c,d,s,n=0;
cin>>a>>c;
for(int i=1;i<=c;i++){
cin>>d>>s;
for(int j=d-1;j<=s-1;j++){
b[j]=1;
}
}
for(int i=0;i<=a;i++){
if(b[i]==0){
n++;
}
}
cout<<n;
return 0;
}
by G_lh @ 2023-07-12 09:13:02
这个
for(int j=d-1;j<=s-1;j++)
改为
for(int j=d;j<=s;j++)
by Augensterm @ 2023-07-12 09:13:10
是
for(int j=d;j<=s;j++)
b[j]=1;
而不是
for(int j=d-1;j<=s-1;j++)
b[j]=1;
QWQ!
by Henry2012 @ 2023-07-12 09:13:40
for(int j=d-1;j<=s-1;j++){
为什么
by tankewei911 @ 2023-07-12 09:16:57
谢谢
by HYHu__Tao @ 2023-07-21 20:12:00
把-1去掉