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.
IF YOU SUCCEED AT ALL EXCEPT ONE TEST CASES, READ THIS POST: With one of the test cases, the numbers are so large that even with a line like this (which seems fine)...
long long CalculateVolume() { return l * b * h; };
...The result of this, while converted to a long long eventually, is originally in integer format during multiplication, causing overflow hence producing a negative volume!
I don't know if there's a more elegant way to do this, but I just decided to do it this way and it worked.
long long CalculateVolume() { return (long long) l * (long long) b * (long long) h; };
The test is poorly designed, as it doesn't account for its own overflows. Nor does it account for modern C++ features or CLANG features.
IF YOU SUCCEED AT ALL EXCEPT ONE TEST CASES, READ THIS POST: With one of the test cases, the numbers are so large that even with a line like this (which seems fine)...
long long CalculateVolume() { return l * b * h; };
...The result of this, while converted to a long long eventually, is originally in integer format during multiplication, causing overflow hence producing a negative volume!
I don't know if there's a more elegant way to do this, but I just decided to do it this way and it worked. long long CalculateVolume() { return (long long) l * (long long) b * (long long) h; };
What is the input format?? The problem is incomplete
Here is Box It! problem solution in C++ - https://programmingoneonone.com/hackerrank-box-it-solution-in-cpp.html
what needs to be called in the main function? There is no definition of it in the problem, thta is causing the test cases to fail.