c求助大神,输出都是对的,但就是全wa

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

a1453084652 @ 2023-04-27 16:05:20

#include<stdio.h>
int main() {
    int l, s, n, i, j, a;
    int arr1[100] = { 0 };
    int arr2[100] = { 0 };
    int arr[10000] = { 0 };
    i = j = 0;
    scanf("%d %d", &l, &n);
   // a = l-1;
   // int arr[a] = {0};
    for (i = 0; i < n; i++) {
        scanf("%d %d", &arr1[i], &arr2[i]);
    }
    for (i = arr1[0]; i <= arr2[0]; i++) {
        arr[i - 1] = 1;
    }
    if (arr1[1]!=0)
    {
        for (i = arr1[1]; i <= arr2[1]; i++) {
            arr[i - 1] = 1;
        }
    }
    if (arr1[2]!=0)
    {
        for (i = arr1[2]; i <= arr2[2]; i++) {
            arr[i - 1] = 1;
        }
    }
    for (i = 0; i <= 10000; i++) {
        if (arr[i]==1)
        {
            j++;
        }
    }
    a = l - j + 1;
    printf("%d", a);
    return 0;
}

by jiangxinyang2012 @ 2023-04-27 16:28:51

@a1453084652 注意数据范围


by a1453084652 @ 2023-04-27 17:10:12

@2021Changqing60 数据取值没有问题啊感觉


by Max6700 @ 2023-04-28 21:27:38

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int s[10000000];//模拟那条路

int main(){

    int n,m;
    cin>>n>>m;//输入基本数据

    for(int i=1;i<=__;i++)//循环多少次?
    {
        int a,b;
        cin>>a>>b;//输入区间首尾
        for(int j=__;j<=__;j++)s[__]=1;//标记此处没树
    }

    int cnt=0;//统计树的棵树

    for(int i=__;i<=__;i++)if(s[__]==0)__++;//注:i要从0开始!到哪结束呢?

    cout<<cnt;//输出
    return 0;
} 

请填空食用


by Max6700 @ 2023-04-28 21:29:55

可以把

cout,cin

换成

printf,scanf

|