90分是什么意思啊

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

you_are_a_idiot @ 2024-02-14 10:24:42

#include<iostream>
#include<cstring>
using namespace std;

bool a[10001];
int main()
{
    memset(a, false, sizeof(a));
    int l, m, ans = 0;
    cin >> l >> m;
    for(int i = 1, s, e;i <= m; i++)
    {
        cin >> s >> e;
        for(int j = s; j <= e; j++)
        {
            a[j] = true;
        }
    }
    for(int i = 1;i <= l + 1;i++){
        if(a[i] == false) ans++;
    }
    cout << ans;
} 

by Li_Yichen @ 2024-02-14 10:27:58

马路端点是会有0的,把最后一个循环改为从0开始到l结束


by xiyihan @ 2024-02-14 10:28:53

@you_are_a_idiot

#include<iostream>
#include<cstring>
using namespace std;

bool a[10001];
int main()
{
    memset(a, false, sizeof(a));
    int l, m, ans = 0;
    cin >> l >> m;
    for(int i = 1, s, e;i <= m; i++)
    {
        cin >> s >> e;
        for(int j = s; j <= e; j++)
        {
            a[j] = true;
        }
    }
    for(int i = 0;i <= l;i++){
        if(a[i] == false) ans++;
    }
    cout << ans;
} 

by you_are_a_idiot @ 2024-02-14 10:51:25

@LYC314159 谢谢


by you_are_a_idiot @ 2024-02-14 10:51:39

@xiyihan 谢谢


|