hgggggg @ 2023-08-06 17:38:07
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a[1001],b[10001];
int h=0;
int n,m;
cin>>n>>m;
int u=2*m;
for(int y=0;y<=n;y++)
{
a[y]=0;
}
for(int i=1;i<=u;i++)
{
cin>>b[i];
}
while((u-2)>=0)
{
for(int j=b[u-1];j<=b[u];j++)
a[j]=1;
u=u-2;
}
for(int p=0;p<=n;p++)
{
if(a[p]=0)
h++;
}
cout<<h;
return 0;
}
by dsfgsdf @ 2023-08-06 18:04:09
@hgggggg
关注了吗?我已经找到哪里错了...
by dsfgsdf @ 2023-08-06 18:05:01
@hgggggg
by dsfgsdf @ 2023-08-06 18:05:33
我居然骗小萌新的关注
by hgggggg @ 2023-08-06 18:05:45
@lfxxzms 嗯嗯嗯,好人大神肯定关注呀
by hgggggg @ 2023-08-06 18:06:04
@lfxxzms where???
by dsfgsdf @ 2023-08-06 18:07:26
@hgggggg 第一个“if(a[p]=1)”改为if(a[p]==1)
by dsfgsdf @ 2023-08-06 18:08:01
@hgggggg 但是还是有问题,你等一下
by hgggggg @ 2023-08-06 18:10:08
@lfxxzms 嗯嗯嗯额
by Heartstrings @ 2023-08-06 18:12:49
@hgggggg 我来了
by Heartstrings @ 2023-08-06 18:13:33
@hgggggg
#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, k, l, a[10005], b[10005], s[10005];
int main(){
scanf("%d", &l);
scanf("%d", &n);
for(i=1; i<=n; i++){
scanf("%d", &a[i]);
scanf("%d", &b[i]);
}
for(i=1; i<=n; i++){
for(j=a[i]; j<=b[i]; j++){
s[j] = 1;
}
}
for(i=0; i<=l; i++){
if(s[i] == 0) m++;
}
printf("%d", m);
return 0;
}