My Solution to this problem (SPCANDY) has been evaluated as wrong. I handled the division by 0 and base 64 integer problems. What is wrong?

This is an annoying quirk of C++. Run your program on this input:

1000000000000 7

and you’ll see that it prints 1.42857e+11 1 instead of the actual numbers you want. The solution to this is to just cast floor(n / k) to a long long, because C++ only uses scientific notation for doubles. The reason you didn’t see this on the samples is because the numbers weren’t big enough, as I believe this only happens when printing a number at least on the order of 10^6.

edit: note that while this input is not valid for the constraints, the same thing would happen for slightly smaller numbers that do fit constraints

1 Like

Thanks. Problem solved :slightly_smiling_face: