Guess the number (March Cook off 2021)

In this question,
when I precompute all those value whose no of factor is odd.
When I submit this It give me wrong answer.
https://www.codechef.com/viewsolution/44031359

Ther only difference is instead of precomputing i directly assign the value

when I submit this solution It give me correct answer.
https://www.codechef.com/viewsolution/44031320

Why this happen any one give me reason…