#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
std::cin >> t;
while(t--)
{
int A,B,X;
cin>>A>>B>>X;
int length=A;
int width=B;
int edgelength=X^2;
if(edgelength>=A*B)
{
cout<<0<<endl;
}
else
}
}
Here is the python version of the code I hope you understand the logic
# cook your dish here
#number of test cases
t = int(input())
#runing the loop for test cases from 0 - (t -1)
for i in range(t):
#taking input for the three variables as mentioned
a, b, x = map(int, input().split())
#calculating are of suare
square = x*x
#calculating area of rectangle
rectangle = a*b
#condition one if area of sqaure is already greater then output = 0
if square >= rectangle:
print(0)
else:
if a > x and b > x:
#if both the dimensions are greater then we have to change either both or once
#changing the greatest dimension 1
if a > b:
a = 1
else:
b = 1
#checking if second dimensionis to be changed or not
if square >= a*b:
print(1)
else:
print(2)
else:
#if only one dimension of rectangle is greater than x we only need to chnage once
print(1)
Basically, you check if both length and height are greater then side or not. if both are greater than side, then change the greatest among the length or height to 1. That will cost you 1 coin. Now if the area of square is still smaller you need to change the other dimension too so now it will cost you 2 coin.
if only one of the length or height is greater then you have to make only single change which will cost you 1 coin