Same code in Java gives RE that gives AC in C++.

c-plus-plus
java

#1

I was doing this question. I implemented the same codes in Java and C++. This java code gives RE while the same code when implemented in C++(here) gives AC. Why is this happening?


#2

In C++, you are using unsigned long long, but in Java you are using long. Range of unsigned long long is two times the range of long. Since, long is not sufficient for this problem and there is no concept as unsigned in Java, you should use BigInteger in Java to get AC.


#3

i dont think they are quite same then