Not able to find my error in FCTRL2 question...please help me

This is my code… :pleading_face:

my answer

please help me…I have spent a lot of time on it. :pray:

Sample test cases are not even running
Refer this

A simple 6-line code in Python will work fine :smiley:
My submission’s link:
https://www.codechef.com/viewsolution/28558958

You can also use Biginteger class of JAVA.
Refer this link:

do the same in cpp…