#1咋调?

P1047 [NOIP2005 普及组] 校门外的树

youngsmart @ 2023-08-26 21:03:39

#include <iostream>
using namespace std;

int a[10005];

int main()
{
    int l, m;
    cin >> l >> m;
    for (int i = 1; i <= m; i++)
    {
        int n, m;
        cin >> n >> m;
        for (int j = n; j <= m; j++)
        {
            if (a[j] == 0)
            {
                ++a[j];
            }
        }
    }
    int cnt = 0;
    for (int i = 1; i <= l; i++)
    {
        if (a[i] == 0)
        {
            ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}

by Rieman_sum @ 2023-08-26 21:10:25

@chengqiuchen 你变量名重复了


by Rieman_sum @ 2023-08-26 21:11:25

@chengqiuchen 有两个M

关注我谢谢!


by youngsmart @ 2023-08-26 21:25:00

@Guo1 还是90


by so_find_skind @ 2023-08-26 21:36:32

@Guo1

没重复啊


by fztt_r9 @ 2023-09-03 18:55:01

@Guo1 i的初始值是0,不是1,而且是小于等于。因为有可能0的地方要处理


|