Aijibaisuilaoren @ 2023-02-26 00:20:11
#include<stdio.h>
int main() {
int i, j, a, b;
int a[100][1000] = 0;
int count = 0;
int x, y;
scanf("%d%d", &i, &j);
for (x = 0; x < i; x++) {
for (int y = 0; y <= j; y++) {
a[x][y] = 1;
}
}
for (x = 0; x < i; x++) {
scanf("%d%d", &a, &b);
for (int y = a; y <= b; x++) {
a[x][y] = 0;
}
}
for (x = 0; x < i;) {
for (int y = 0; y <= j; y++)
count = count + a[y][x];
}
printf("%d", count);
return 0;
}
by cn_ryh @ 2023-02-26 07:28:39
@Aijibaisuilaoren 你先定义的变量
by Aijibaisuilaoren @ 2023-03-03 10:45:17
@ryh2007316 草率了
by liuzekai123 @ 2023-03-03 23:28:15
using namespace std;
int s[100005];
int main()
{
int L,M,cnt=0,a,b;
cin>>L>>M;
for(int i=1;i<=M;i++)
{
cin>>a>>b;
for(int j=a;j<=b;j++) s[j]=1;
}
for(int i=0;i<=L;i++)
{
if(s[i]==0)
{
cnt++;
}
}
cout<<cnt;
return 0;
}**对一下**