I was working on problem from like past day, I got WA in c++ in couple of test cases, as a result I switched to Python 3. 6 and that’s where I found a thing which can give you WA frequently. It is related to large numbers.
For eg:
py print((2001100545* 2001100544)/2)
will print 2.0022016945990984e+18
and doing it modulo with 10**9 + 7 will give 583686608.0
.
But if we do so with C++ or python 2x…
it will give 584787011
.
See the difference ^^.
In such cases python 2x will returns right answer because it have long type and interpreter automatically decides, which type i.e. int
or long
is to be used.