Cod sursa(job #951707)
| Utilizator | Data | 21 mai 2013 15:00:38 | |
|---|---|---|---|
| Problema | Divk | Scor | 90 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <fstream>
using namespace std;
long long rest[100005],val[500005];
long long n,a,b,k,count,x,ans=0;
int main(){
ifstream in("divk.in");
ofstream out("divk.out");
in>>n>>k>>a>>b;
for(int i=1;i<=n;i++){
in>>x;
count=(count+x)%k;
val[i]=count;
if((i-a)>=0)
rest[val[i-a]]++;
if((i-b-1)>=0)
rest[val[i-b-1]]--;
if(rest[count]!=0)
out<<"";
ans+=rest[count];
}
out<<ans;
return 0;
}