Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I think
std::floor(result * 1000000) / 1000000;
should work fine. You might want to look at the result before truncating, because 1146652 is rouned up.Thank you! All the tests passed successfully. I too, am all for a BigInteger library. It will benefit many katas similar to this one.
I still believe there is overflow occurring before the check against ULLONG_MAX - 1000. For example, diagonal(183, 19) must be greater than diagonal(80, 19) but the random tests expect values of 401227812924226601 and 762367057337870191 respectively.
My code passes many of the smaller value random tests such as diagonal(77, 16), so I assume my approach is not completely unreasonable.
Oh, by writing 2.79e+26 I don't imply that that's the return type. It is just easier to compare the numbers this way instead writing 278635918444896000000000000 and 401227812924226601 in the comment(with some precision lost).
My code returns unsigned long long, but the result of some of the random tests doesn't fit in 64 bits.
This comment is hidden because it contains spoiler information about the solution