Help me in solving BIN_BAT problem

My issue

can anyone tell me the error i have run three test cases succesfully but i cant figure out where i did wrong

My code

# cook your dish here
import math 
t=int(input())
for i in range(t):
    n,a,b=map(int,input().split())
    sq=int(math.sqrt(n))
    d=sq-1
    print(int((sq*a)+(d*b)))

Problem Link: BIN_BAT Problem - CodeChef

@vaishnavi_910
Your code is failing for the test case
1
1024 23 9
the answer should be
311
but your output is
1015