huajianyu_1323 @ 2024-12-30 13:57:34
#include <bits/stdc++.h>
using namespace std;
int main () {
int l, m, u, v, c = 0;
cin >> l >> m;
int a[l + 1];
for (int i = 0; i <= l; i++) {
a[i] = 1;
}
for (int i = 1; i <= m; i++) {
cin >> u >> v;
}for (int i = u; i <= v; i++){
a[i] = 0;
}
for (int i = 0; i <= l; i++) {
if (a[i] == 1) {
c++;
}
}
cout << c;
return 0;
}
为什么错了?求解答
by bsdsdb @ 2024-12-30 14:36:57
for (int i = 1; i <= m; i++) {
cin >> u >> v;
}for (int i = u; i <= v; i++){
a[i] = 0;
}
下面的要套到上面里面