Cod sursa(job #1462432)
| Utilizator | Data | 18 iulie 2015 00:49:54 | |
|---|---|---|---|
| Problema | Divk | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <cstdio>
using namespace std;
int N, M, sol;
int V[DIM], P[DIM], S[DIM];
int main(){
freopen("divk.in" ,"r", stdin );
freopen("divk.out","w", stdout);
scanf("%d %d %d %d", &N, &K, &A, &B);
for(int i = 1; i <= N; i ++){
scanf("%d", &V[i]);
P[i] = ( P[i-1] + V[i] ) % K;
if(i > A)
S[ P[i-A-0] ] ++;
if(i > B)
S[ P[i-B-1] ] --;
sol += S[ P[i] ];
}
printf("%d\n", sol);
fclose(stdin );
fclose(stdout);
return 0;
}