Cod sursa(job #2034706)

Utilizator valentinoltyanOltyan Valentin valentinoltyan Data 8 octombrie 2017 12:44:11
Problema Divk Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <iostream>
#include <fstream>

using namespace std;
ifstream f("divk.in");
ofstream g("divk.out");
int main()
{
    int x[500000];
    int k,a,b,n;
    int nr=0;
    f>>n>>k>>a>>b;
    for(int i=1;i<=n;i++)
        f>>x[i];
    for(int i=1;i<n;i++)
    {
        for(int j=i;j<=n;j++)
        {
            if(j-i<=b-a)
            {
                long long s=0;
                for(int c=i;c<=j;c++)
                    s+=x[c];
                if(s%k==0) nr++;
            }
        }

    }
    g<<nr;
    return 0;
}