I was doing Atcoder Beginner Contest yesterday.For problem C i counted the number of factors of n-c
for all valid c. In order to precompute number of factors for numbers in range [1,1e6]. I tweaked seive like this:
vi := vector
vi factorize (vi v){
v[0]=0;
v[1]=1;
for(int i=2;i<N;i++)
v[i]=1; //counting 1 as a factor for all numbers>=1
for(int i=2;i<N/2;i++)
for(int j=i;j<N;j+=i){
v[j]+=1;
}
return v;
}
But it may accidentally have worked for first two cases but didn’t work for n=1e6
(The last sample case)
please help me find where did it went wrong?
Thank You in advance
Update : I got my mistake