Ad
  • Default User Avatar

    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.

  • Default User Avatar

    Thank you! All the tests passed successfully. I too, am all for a BigInteger library. It will benefit many katas similar to this one.

  • Default User Avatar

    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.

  • Default User Avatar

    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.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution