Cod sursa(job #1780669)
| Utilizator | Data | 16 octombrie 2016 14:51:49 | |
|---|---|---|---|
| Problema | Divk | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <iostream>
#include<fstream>
using namespace std;
int x,sum[500005],ap[100005],i,n,k,a,b,j1,j2;
long long tot;
int main()
{
ifstream f("divk.in");
ofstream g("divk.out");
f>>n>>k>>a>>b;j1=0;j2=0;
for(i=1;i<=n;i++)
{
f>>x;
sum[i]=sum[i-1]+x;
sum[i]%=k;
if(i-j1>=a) {ap[sum[j1]]++;j1++;}
if(i-j2>=b+1) {ap[sum[j2]]--;j2++;}
tot+=(1LL)*ap[sum[i]];
}
g<<tot;
return 0;
}
