1. '''
  2. # Sample code to perform I/O:
  3.  
  4. name = input() # Reading input from STDIN
  5. print('Hi, %s.' % name) # Writing output to STDOUT
  6.  
  7. # Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
  8. '''
  9.  
  10. # Write your code here
  11. from sys import stdin,stdout
  12.  
  13. def main():
  14. T=int(stdin.readline())
  15. for i in range(T):
  16. N,A,B=map(int, stdin.readline().split())
  17. X1=round((B*N)/(A+B))
  18. Y1=N-X1
  19. stdout.write(str(A*X1*X1+B*Y1*Y1)+'\n')
  20. main()
Language: Python 3