Learning course: Logic Building in Java
Problem Link: CodeChef: Practical coding for everyone
Feedback
my output is as expected but it is showing wrong answer
Learning course: Logic Building in Java
Problem Link: CodeChef: Practical coding for everyone
my output is as expected but it is showing wrong answer
@prerna_p
plzz refer the following solution for better understanding of logic.
// Solution as follows
import java.util.Scanner;
class Codechef
{
public static void main (String[] args)
{
Scanner read = new Scanner(System.in);
int t = read.nextInt();
for(int i=0; i<t; i++){
int A = read.nextInt();
int C = read.nextInt();
// Borrow the solution template from the sub-components
if (A%2 == 0 && C%2 == 0){
int B = (A + C)/2;
System.out.println(B);
}
else if (A%2 != 0 && C%2 != 0){
int B = (A + C)/2;
System.out.println(B);
}
else{
System.out.println(-1);
}
}
}
}