Cod sursa(job #3303485)

Utilizator Andrei-Dani-10Pisla Andrei Daniel Andrei-Dani-10 Data 15 iulie 2025 21:20:05
Problema Divk Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.47 kb
#include <fstream>

using namespace std;

ifstream in("divk.in");
ofstream out("divk.out");

const int nmax = 5 * 1e5;
int n, k, lf, rg, a[nmax + 2];
int64_t secv;

int main(){

    in>>n>>k>>lf>>rg;
    for(int i = 1; i <= n; i++)
        in>>a[i], a[i] += a[i - 1];

    for(int i = 1; i <= n; i++){
        for(int j = max(1, i - rg + 1); j <= i - lf + 1; j++)
            secv += ((a[i] - a[j - 1]) % k == 0);
    }

    out<<secv<<"\n";;

    return 0;
}