Help me in solving LBC18 problem

My issue

My code

// Update the code below to solve this problem

#include <iostream>
#include <string>
using namespace std;

int main() 
{
  int t;
  cin>>t; 
  while(t--)
  {
  int X, Y, Z;
  cin>>X>>Y>>Z;
  
   }
return 0;
}

Learning course: Solve Programming problems using C++
Problem Link: CodeChef: Practical coding for everyone

@hkbharti77
its simple maths u can do it in O(1);
I have coded it in much simpler way hope u will get it.

// Update the code below to solve this problem

#include <iostream>
#include <string>
using namespace std;

int main() 
{
  int t;
  cin>>t; 
  while(t--)
  {
  int X, Y, Z;
  cin>>X>>Y>>Z;
  int ans=X*Y;
  int q=X/3;
  if(X%3==0)
  q--;
  ans+=(q*Z);
  cout<<ans<<endl;
   }
return 0;
}