Cod sursa(job #2480515)
Utilizator | Data | 25 octombrie 2019 18:32:27 | |
---|---|---|---|
Problema | Divk | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <fstream>
using namespace std;
ifstream cin ("divk.in");
ofstream cout ("divk.out");
int n, k, a, b, dp[500010], rest[100010], i;
long long ans;
int main() {
cin >> n >> k >> a >> b;
for (i=1; i<=n; i++) {
cin >> dp[i];
dp[i] = (dp[i] + dp[i-1])%k;
if (i >= a)
rest[dp[i - a]]++;
if (i - b >= 1)
rest[dp[i - b - 1]]--;
ans += rest[dp[i]];
}
cout << ans;
return 0;
}