Same code different behaviour

Solution link (TLE) : https://codeforces.com/contest/1451/submission/99250735

Solution link (Accepted): https://codeforces.com/contest/1451/submission/99250995

Question Link :
https://codeforces.com/contest/1451/problem/D

Why is there TLE , both are having the same procedure and approach ?

Most probably , expression dis=xx+yy
will be overflow as x and y are of type integer , variable dis will become negative(dis<0) and hence it never comes out of while loop

2 Likes

Okay . Thanks @nihar_99