My issue
this fails in few test cases.
My code
import java.util.Scanner;
class Codechef {
public static void main(String[] args) throws java.lang.Exception {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int i = 0; i < t; i++) {
int x = sc.nextInt();
int y = sc.nextInt();
int z = sc.nextInt();
boolean flag = true;
if (y % z == 0)
{
System.out.println("-1");
}
else
{
int k = x + 1;
if (k % y != 0) {
k = k + y - (k % y);
while (k % z == 0) {
k += y;
}
System.out.println(k);
}
}
}
sc.close();
}
}
Problem Link: CodeChef: Practical coding for everyone