Cod sursa(job #1652276)
Utilizator | Data | 14 martie 2016 20:43:45 | |
---|---|---|---|
Problema | Divk | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.42 kb |
#include <iostream>
#include <fstream>
using namespace std;
int s[500001],rest[100001];
int main()
{int i,j,n,k,a,b,x;
long long nr=0;
fstream f("divk.in",ios::in);
fstream g("divk.out",ios::out);
rest[0]=0;
f>>n>>k>>a>>b;
f>>s[1];
for(i=2;i<=n;i++)
{f>>x;
s[i]=s[i-1]+x;
s[i]=s[i]%k;
if(i>a)
rest[s[i-a]]++;
if(i>b)
rest[s[i-b-1]]--;
nr=nr+rest[s[i]];
}
g<<nr;
}