hi everyone. I'm having a doubt in problem 839D. The link is here http://codeforces.me/problemset/problem/839/D
I submitted a solution which gives me wrong answer on test 44. The link is here. https://ideone.com/tJhWMt
But i just modified the line number 57 from ans[i] = gcd[i] * p2[max(gcd[i] — 1, (int)0)]; to
ans[i] = (gcd[i] * p2[max(gcd[i] — 1, (int)0)]) % mod; where mod is 10^9 + 7. And it got accepted
My question is even though we don't take the mod value in line 59, in line number 60 after the execution of the 1st inner for on line 59, it will automatically take modulus and by any means ans[i*j], on line 60 wont be greater than 10^9 + 6. So why is the mod on line 57 even necessary. Plz help. Thanks in advance