Cod sursa(job #1019491)
| Utilizator | Data | 31 octombrie 2013 11:18:10 | |
|---|---|---|---|
| Problema | Divk | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <fstream>
#define Nmax 500005
using namespace std;
ifstream eu("divk.in");
ofstream tu("divk.out");
int X[Nmax],S[Nmax],P[Nmax],K,N,a,b;
long long contor;
void Read()
{
eu>>N>>K>>a>>b;
for(int i=0;i<=N;i++)
{
eu>>S[i];
S[i]=(S[i-1]+S[i])%K;
}
}
void Solve()
{
for(int i=a;i<=N;i++)
{
P[S[i-a]]++;
if(i>b)
P[S[i-b-1]]--;
contor+=P[S[i]];
}
}
void Print()
{
tu<<contor<<"\n";
}
int main()
{
Read();
Solve();
Print();
return 0;
}
