Back to Problem Solutions forum
Hi, I do not understand, why the server does not consider the right my decision:
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int a = scn.nextInt();
for (int i = 0; i < a; i++) {
int b = scn.nextInt();
int c = scn.nextInt();
int d = scn.nextInt();
System.out.println(((2*b + c * (d - 1)) / 2) * d + " ");
}
}
}
My decision is based on this formula:
Use floats when dividing and then cast the final answer to an int.