Cod sursa(job #3349538)
| Utilizator | Data | 31 martie 2026 13:40:45 | |
|---|---|---|---|
| Problema | Divk | Scor | 30 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.66 kb |
#include <bits/stdc++.h>
using namespace std;
signed main() {
ifstream cin("divk.in");
ofstream cout("divk.out");
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, k, x, y; cin >> n >> k >> x >> y;
vector <int> a(n + 2);
for (int i = 1; i <= n; i ++) {
cin >> a[i];
}
vector <int> s(k);
int ans = 0;
for (int i = 0; i <= n; i ++) {
a[i + 1] += a[i];
if (i - x >= 0) {
s[a[i - x] % k] ++;
}
if (i - y - 1 >= 0) {
s[a[i - y - 1] % k] --;
}
ans += s[a[i] % k];
}
cout << ans << '\n';
}