Cod sursa(job #2067087)
| Utilizator | Data | 15 noiembrie 2017 20:15:11 | |
|---|---|---|---|
| Problema | Divk | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.61 kb |
#include<fstream>
using namespace std;
ifstream fin("divk.in");
ofstream fout("divk.out");
long long Sume[500010];
long long N,K,A,B,Rest[100010]={1},Sol;
int main()
{
fin>>N>>K>>A>>B;
for(int i=1;i<=N;i++)
{
int x;
fin>>x;
Sume[i]=Sume[i-1]+x;
}
if(Sume[A]%K==0)
Sol++;
for(int i=A+1;i<=N;i++)
{
if(i>B)
{
Rest[Sume[i-B]%K]--;
if(i==B+1)
Rest[0]--;
}
Rest[Sume[i-A]%K]++;
Sol+=Rest[Sume[i]%K];
}
fout<<Sol<<'\n';
}
