We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
That's because "long long int" uses 64 bits, hence, the range is from -2^63 to 2^63-1. Since, the range for N (mentioned in "Constraints") is 0 to 2^64-1, it can't be stored properly in "long long int" and hence gives wrong result.
Instead, using "unsigned long long int" (still using 64 bits), the range becomes 0 to 2^64-1, which is the required range for N.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Counter game
You are viewing a single comment's thread. Return to all comments →
That's because "long long int" uses 64 bits, hence, the range is from -2^63 to 2^63-1. Since, the range for N (mentioned in "Constraints") is 0 to 2^64-1, it can't be stored properly in "long long int" and hence gives wrong result.
Instead, using "unsigned long long int" (still using 64 bits), the range becomes 0 to 2^64-1, which is the required range for N.