# Help me in solving TEA problem

### My code

``````/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner in=new Scanner(System.in);
int t=in.nextInt();
for(int i=0;i<t;i++){
int x=in.nextInt();
int y=in.nextInt();
int z=in.nextInt();
int div=x/y;
int rem=x%y;
int out;
if(x<=y){
System.out.println(z);
}
else{
out=z*(div+rem);
System.out.println(out);
}
}
}
}

``````

Problem Link: TEA Problem - CodeChef

@chikurajiv2003
i used cpp to solve but the logic is pretty same so…
you just have to look out for the cases in which u dont get a int after dividing the numbers .(x/y)
so u can use math.ceil() in java to round off to the nearest greater int .
once you have done that , you can multiply your ans with cost(z) and you are good to go.

i have pasted my correct code below hope this helps

include <bits/stdc++.h>
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while(t–)
{
double x,y,z;
cin>>x>>y>>z;
double ans=ceil(x/y);
cout<<ans*z<<endl;
}
return 0;
}