Why is this code giving TLE while a similar solution is getting accepted

Problem - https://www.codechef.com/problems/QNUMBER

My Solution (TLE) - https://www.codechef.com/viewsolution/47927664

Accepted Solution - https://www.codechef.com/viewsolution/34623272

Consider the test input:

9999999969 1
1 1

Thanks a lot dude!! Got accepted
Just a little more clarification needed.

Was the main problem with integer overflow? or with orig[i] getting updated unnecessarily?

Integer overflow - it prevented the for loop in factorize from ever terminating :slight_smile:


Remember that you can usually detect overflows by turning them into Runtime Errors.

1 Like

Whoa that article is really really helpful. Big thanks brother :fist_right: :fist_left:

1 Like