young_young_123 @ 2024-06-28 12:45:09
#include<bits/stdc++.h>
using namespace std;
int n,m,ji=0;
int a[1010];
int main(){
cin>>n>>m;
for(int i=0;i<=n;i++){
a[i]++;
}
for(int i=0;i<m;i++){
int x,y;
cin>>x>>y;
for(int j=x;j<=y;j++){
a[j]=0;
}
}
for(int i=0;i<=n;i++){
ji+=a[i];
}
cout<<ji;
return 0;
}
by hongshixiaobai @ 2024-06-28 13:06:40
@young_young_123 有没有一种可能,
by Evelyn_wsx_star @ 2024-06-28 13:09:38
@young_young_123
10^4=10000,所以a开小了
by Evelyn_wsx_star @ 2024-06-28 13:11:16
#include<bits/stdc++.h>
using namespace std;
int main(){
int a[10005]={},b,c,d,e,s=0;
cin>>b>>c;
for(int i=1;i<=c;i++){
cin>>d>>e;
for(int j=d;j<=e;j++){
a[j]=1;
}
}
for(int i=0;i<=b;i++){
if(a[i]==0){
s++;
}
}
cout<<s;
return 0;
}
by Evelyn_wsx_star @ 2024-06-28 13:12:56
@hongshixiaobai 是的
by Evelyn_wsx_star @ 2024-06-28 13:13:28
@xhsymwx_wsx @young_young_123