Help me in solving ABPLUSC problem

My issue

My code

for _ in range(int(input())):
    x=int(input())
    if x==1:
        print(-1)
    elif x==2:
        print(1, 1, 1)
    else:
        if x<=1000000:
            print(x-1, 1, 1)
        else:
            r=int(x**0.5)
            print(r,r-1,x-r*(r-1))

Problem Link: ABPLUSC Problem - CodeChef

I don’t actually see an issue with this code. It is failing for one particular test case. I can’t even figure that out. Please help me.

your code is failing for x=999999999999 . for this u will get one c>1000000 which is not allowed . for this u will get correct answer if u take r,r+1 as A and B instead of r,r-1. so the over all solution will lies in r,r or r,r-1 or r,r+1 thats it .

1 Like