Cod sursa(job #669719)
Utilizator | Data | 27 ianuarie 2012 16:39:03 | |
---|---|---|---|
Problema | Divk | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <fstream>
using namespace std;
long long sum[500001];
int fv[100002];
int main()
{
ifstream f("divk.in");
ofstream g("divk.out");
int N,K,A,B,x,i,nrs=0;
f>>N>>K>>A>>B;
for(i=1;i<=N;i++)
{
f>>x;
if(i>B)
fv[sum[i-B-1]]--;
if(i>=A)
fv[sum[i-A]]++;
sum[i]=(sum[i-1]+x)%K;
//fv[sum[i]]++;
nrs+=fv[sum[i]];
//g<<"am citit "<<x<<", sum e "<<sum[i]<<" si nrs a crescut cu "<<fv[sum[i]]<<"\n";
}
g<<nrs<<"\n";
}