51nod 1094 【水题】

暴力即可!!!

#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;

typedef long long LL;

const int N=1e4+10;

LL a[N];
int n;

int main()
{
    int s,t;
    LL sum=0,k;
    scanf("%d%lld",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    bool flag=false;
    for(s=1;s<=n;s++)
    {
        sum=a[s];
        if(sum==k)
        {
            printf("%d %d
",s,s);
            return 0;
        }
        t=s+1;
        while(t<=n)
        {
            sum+=a[t];
            if(sum==k)
            {
                printf("%d %d
",s,t);
                return 0;
            }
            t++;
        }
    }
    if(!flag)
        printf("No Solution
");
    return 0;
}

原文地址:https://www.cnblogs.com/keyboarder-zsq/p/5934841.html