Pagini recente » Cod sursa (job #1926372) | Cod sursa (job #2334153) | Cod sursa (job #2201870) | Cod sursa (job #2046988) | Cod sursa (job #974049)
Cod sursa(job #974049)
#include<fstream>
#define NMAX 500005
using namespace std;
ifstream f("divk.in");
ofstream g("divk.out");
int sum[NMAX];
int ap[NMAX];
int N,K,a,b;
unsigned long long Ans;
int main ( void )
{
f>>N>>K>>a>>b;
for( int i(1) ; i <= N ; ++i )
{
int x;
f>>x;
sum[i]=(sum[i-1]+x) % K;
}
for( int i(1) ; i <= N ; ++i )
{
if( i >=a )
++ap[sum[i-a]];
if( i > b)
--ap[sum[i-b+1]];
Ans+=ap[sum[i]];
}
g<<Ans;
f.close();
g.close();
return 0;
}