Pagini recente » Cod sursa (job #2858193) | Cod sursa (job #349837) | Cod sursa (job #1378937) | Cod sursa (job #2782396) | Cod sursa (job #723847)
Cod sursa(job #723847)
#include <fstream>
using namespace std;
int i,j,h,n,k,a,b,t=0;
long v[500000];
long long s;
int main()
{
ifstream inf("divk.in");
inf >> n >> k >> a >> b;
for (i=0; i<n; i++)
inf >> v[i];
inf.close();
for (j=a; j<=b; j++)
{
s=0;
for (i=0; i<j; i++)
s+=v[i];
if (s%k==0)
t++;
for (h=j; h<n; h++)
{
s+=v[h]-v[h-j];
if (s%k==0)
t++;
}
}
ofstream outf("divk.out");
outf << t << '\n';
outf.close();
return 0;
}