Cod sursa(job #764398)
| Utilizator | Data | 5 iulie 2012 09:24:12 | |
|---|---|---|---|
| Problema | Divk | Scor | 90 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.47 kb |
#include<fstream>
using namespace std;
#define NN 500001
ofstream out("divk.out");
int v[NN],uz[NN],n,A,B,ans,k;
void read();
void solve();
int main()
{
read();
solve();
out<<ans<<'\n';
return 0;
}
void read()
{
ifstream in("divk.in");
in>>n>>k>>A>>B;
for(int x,i=1;i<=n;i++)
{
in>>x;
v[i]=(v[i-1]+x)%k;
}
}
void solve()
{
for(int i=A;i<=n;i++)
{
++uz[v[i-A]];
if(i>B)
--uz[v[i-B-1]];
ans+=uz[v[i]];
}
}
