Cod sursa(job #2180770)
Utilizator | Data | 21 martie 2018 09:48:22 | |
---|---|---|---|
Problema | Divk | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <fstream>
using namespace std;
ifstream f("divk.in");
ofstream g("divk.out");
int n,k,A,B,i,j;
long long x[500010],rest[100002],rez;
int main()
{
f>>n>>k>>A>>B;
for(i=1;i<=n;i++){
f>>x[i];
x[i]=(x[i]+x[i-1])%k;
if(i>=A) rest[x[i-A]]++;
if(i-B>=1)rest[x[i-B-1]]--;
rez=rez+rest[x[i]];
}
g<<rez<<'\n';
return 0;
}