Cod sursa(job #669720)
Utilizator | Data | 27 ianuarie 2012 16:40:15 | |
---|---|---|---|
Problema | Divk | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.57 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;
long long 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";
}