CHFING use of modulo

I submitted this code for CHFING chef and ingredients, in june challenege but got 20pts, the second testcase in subtask 2 was wrong, can someone help me find what Im missing

This is because, you lost some value during dividing, because there can be case when it’s not divisible, so when you multiplied it later, answer is different than expected.
Like (3/2)*2 will give 2 instead of 3.
Try changing it into float temporarily. I got WA in same case, so submitted it in python and go AC for same code.


had a similar problem :confused:
i changed my code into python it worked

1 Like

Python is useful to deal with floating stuff and holding large numbers.

1 Like

i had trouble in keeping the formula
so many times i had to typecast or something
i got frustrated and changed it to python XD

It is an overflow problem . Since long long int can support only upto 2^64 -1 and Python has no limit for int your code worked.
Use Modulo correctly or refer to my solution.