FRJUMP - Editorial

How do I get an idea of this type of solution?

Can anyone explain me the setter’s code:
for (int i=1; i<=min(pos-1, sq); i++){
if ((pos-1)%i==0){
dig[i]-=log10(a[pos]+0.0);
dig[i]+=log10(val+0.0);
remain[i]=inv;
remain[i]%=inf;
remain[i]
=val;
remain[i]%=inf;
Should’nt this be just min(pos,sq) as the setter had done 1 based indexing in his code?

i am using the same algo as given in solution still i am getting only 95 points. plz help.
solution link-
https://www.codechef.com/viewsolution/10910270

Not sure but I had testcases failing due to precision. Had to add a small precision check, EPS = 1E-9 to avoid WA on certain testcases.

1 Like

you are decomposing a number r into two products r = a * b. Where a <= b. Hence you need to search until square root of r only to find a and b. Hence, the name square root decomposition.

i don’t think that is what square root decomposition means…

not sure about the TLE, but I had the same problem with WA…one testacse was WA for me too. It is probably because of precision handling.

Umm… I am sorry, I did not quite get what you mean to say. Can you please give me some link to solution which is the implementation of what you are trying to convey?

So,precision handling technique changes with language version ?

I had to do the same (EPS = 1E-10), but I can’t see that check in grebnesieh’s solution.

@lohit_97 check this out KOL15C - Editorial - editorial - CodeChef Discuss

@adkroxx Thanks, I will check that out for sure!

You are missing out for test where you query with R = 1 as in:

3
2 8 5
1
2 1

Setting a[n+1]=1 fixes that though

probably… updated versions might use updated pow functions right

Problem is with precision.

can someone tell me whats wrong with my solution :https://www.codechef.com/submit/complete/29922201

I am doing the same thing as the editorial… storing answer of each r