C++很简单

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

yjz161616 @ 2024-12-03 20:53:45

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l,m;
    cin>>l>>m;
    int v[10005]={};
    int a,b;
    for(int i=1;i<=m;i++)
    {
        cin>>a>>b;
        for(int j=a;j<=b;j++)
        {
            v[j]=1;
        }
    }
    int sum=0;
    for(int i=0;i<=l;i++)
    {
        if(v[i]==0)
        {
            sum++;
        }
    }
    cout<<sum<<endl;
    return 0;

 } 

by _Vistion_ @ 2024-12-03 20:55:19

wyy,jbl


by Grammar__hbw @ 2024-12-03 20:56:54

投票:wyy,jbl(点击选项进行投票):
wyy,jbl
tlqtj,jbl
锟斤拷


|