Below is the Java code:
https://www.codechef.com/viewsolution/37018715
Below is the C++ code:
https://www.codechef.com/viewsolution/37018744
They give the Desired Output but The System Won’t Take it in. I tested it on Random Values too. But no luck.
Please Help.