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 17:54:15
@hgggggg
鄙人不才,只能为您提供我们的思路..
by Heartstrings @ 2023-08-06 17:54:43
@hgggggg 按理来说没问题
但是会麻烦很多
也容易出bug
但是我吃饭去了
by dsfgsdf @ 2023-08-06 17:54:54
@hgggggg
#include<bits/stdc++.h>
using namespace std;
int l,m,a,b,c[10005]={0},geshu;
int main(){
cin>>l>>m;
for(int i=0;i<m;i++){
cin>>a>>b;
for(int j=a;j<=b;j++){
c[j]=1;
}
}
for(int k=0;k<=l;k++){
if(c[k]==0) geshu++;
}
cout<<geshu;
return 0;
}
by hgggggg @ 2023-08-06 17:57:12
@lfxxzms 好人,你呢能告诉我为啥不行吗
by hgggggg @ 2023-08-06 17:57:50
@lonely_conqueror 呜呜呜呜呜,告诉我,球球了,你吃完了记得高数我
by hgggggg @ 2023-08-06 17:58:33
@lfxxzms 好人,我想知道为啥我这个不行,你呢能个帮我找到错误吗
by hgggggg @ 2023-08-06 17:59:09
@lfxxzms 我刚学两天就被卡住了,我这个思路为啥子得不到答案
by hgggggg @ 2023-08-06 17:59:57
@lfxxzms 谢谢你的帮助,那个我可以理解,但我想知道自己那个,阿里嘎多
by dsfgsdf @ 2023-08-06 18:00:29
@hgggggg
看在你叫我好人的份上()
彳亍,口巴...
by dsfgsdf @ 2023-08-06 18:02:19
@hgggggg
关注我一下以后有问题我可以帮帮你(能力范围之内)