Help me to solve GUMP

Problem link : https://www.codechef.com/problems/GUMP
https://pastebin.com/qqhsMu6H

here is my code. I’m getting WA.But i cann’t understand why?
My logic:

the maximum ans will be x^n where
x=(s/n)
but if x%n!=0
then I increase Y x by one
where
y=s%n
now the maximum ans will be X(n−y)∗(X+1)y

Can anyone tell me why I am getting WA?Is my logic is wrong?If wrong,then why?
Can you provide a test case for which my code will give WA?

Thanks in advance :slightly_smiling_face::slightly_smiling_face:

This would give AC if all elements of the sequence are integers but according to the question the elements are just numbers so fractions are included as well.
The answer would now be ((s/n)^n % MOD). So some modular inverse would be required as well.

Here is your solution with AC.
https://www.codechef.com/viewsolution/24429168

1 Like

@aert has mentioned it correctly here. Also, I have just written an answer on the Editorial Page of this problem. Do have a look.