little elephant and music wrong answer

helo all,
I am getting wrong answer in this question here my solution here is simple and close to the editorial the problem is easy . I tried large input and it works . if someone could tell me where I am wrong or give me a wrong test case it will be much appreciated , cheers.

@muhammedabuali
Your approach is correct.

This is the Accepted solution. I just changed some variable types to “long long int” and it was accepted.

If you have to multiply 2 numbers whose product cannot be stored in an int type variable, then the two numbers multiplied should also be “long long int”.
For example:
if you have to perform c=a*b and a=10^9 and b=10, then a,b and c all should be “long long int” type.

1 Like

The answer about c = a*b is not exact. Basically only c have to be long long, because a and b fits in int, but compiler have to know, that you really do not want int overflow, but long long calculation. You can achieve this by casting or multiplying by 1LL.

Of course having all as long long is the simple and safe approach.

Your link to ideone is not working for me, but you can link to your solution in practice section :wink:

My bad!! I forgot to make my code public.

No problem, secret is almost always better than public :smiley:

1 Like

sorry for the late reply . but that’s an annoying issue thanks