Pagini recente » Cod sursa (job #877629) | Autentificare | Cod sursa (job #2441291) | Cod sursa (job #1588564) | Cod sursa (job #1424356)
#include<fstream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
typedef int64_t var;
ifstream fin("divk.in");
ofstream fout("divk.out");
#define MAXN 500002
var V[MAXN];
var n, k;
var Count[100000];
var SUM[MAXN];
var Solve(var a) {
memset(Count, 0, sizeof(Count));
Count[0] = 1;
var sol = 0;
for(var i=a, j=1; i<=n; i++, j++) {
sol += Count[SUM[i]%k];
Count[SUM[j]%k]++;
}
return sol;
}
#define DIM 100000
char buff[DIM];
var poz;
void Read(var &a) {
a = 0;
while(!isdigit(buff[poz]))
if(++poz == DIM)
fin.read(buff, DIM), poz=0;
while(isdigit(buff[poz])) {
a = a*10 + buff[poz] - '0';
if(++poz == DIM)
fin.read(buff, DIM), poz=0;
}
}
int main() {
var a, b;
fin.read(buff, DIM);
Read(n);
Read(k);
Read(a);
Read(b);
for(var i=1; i<=n; i++) {
Read(SUM[i]);
SUM[i] += SUM[i-1];
}
fout << Solve(a) - Solve(b+1);
return 0;
}