-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA 1077 - Frog Jumping.java
44 lines (35 loc) · 1.26 KB
/
A 1077 - Frog Jumping.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
long [] [] data = new long [input.nextInt()] [3];
long hasil = 0,a,b,x;
for (int i = 0; i < data.length; i++) {
for (int j = 0; j < data[i].length; j++) {
data [i] [j] = input.nextLong();
}
}
for (int i = 0; i < data.length; i++) {
hasil = 0;
a = data [i] [0];
b = data [i] [1];
x = data [i] [2];
if(a == b){
if(x%2 == 0){
System.out.println(0);
}else{
System.out.println(a);
}
}else{
if(x % 2 == 1){
hasil = a*((x /2)+1);
hasil = hasil - (b * (x/2));
}else{
hasil = a*(x/2);
hasil = hasil - (b*(x/2));
}
System.out.println(hasil);
}
}
}
}