Cod sursa(job #3202663)
Utilizator | Mihai iubeste baietii Mihai09 | Data | 12 februarie 2024 10:06:55 |
---|---|---|---|
Problema | Divk | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("divk.in");
ofstream fout("divk.out");
int n,k,a,b,x,s[500001],ans;
int main()
{
fin >>n >>k >>a >>b;
for(int i = 1;i <= n;i++)
{
fin >>x;
s[i] = (s[i-1]+x)%k;
}
for(int i = 1;i+a-1 <= n;i++)
{
for(int j = i+a-1;j <= i+b-1 && j <= n;j++)
{
if(s[i] == s[j])
{
ans++;
}
}
}
fout <<ans;
return 0;
}