Cod sursa(job #2503387)
Utilizator | Hosu Iulia Iulia25 | Data | 2 decembrie 2019 23:11:30 |
---|---|---|---|
Problema | Divk | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <fstream>
using namespace std;
ifstream fin ("divk.in");
ofstream fout ("divk.out");
long long n, k, a, b, x, ans;
long long sp[500005], nr[100005];
int main() {
fin >> n >> k >> a >> b;
++b;
for (int i = 1; i <= n; ++i) {
fin >> x;
sp[i] = sp[i - 1] + x;
sp[i] %= k;
if (i >= a)
++nr[sp[i - a]];
if (i >= b)
--nr[sp[i - b]];
ans += nr[sp[i]];
}
fout << ans;
return 0;
}