-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathP11231.java
executable file
·42 lines (39 loc) · 945 Bytes
/
P11231.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
import java.util.Scanner;
public class P11231 {
private static long gib(long n, long m, int c) {
if(c == 0) { // Bottom right corner is black:
/*
XOXOXOXOXO
1Y1Y1Y1Y1Y
XOXOXOXOXO
*/
--n;
long fromXGrid = ((m-6)/2) * ((n-6)/2);
++n; --m;
long fromYGrid = ((m-6)/2) * ((n-6)/2);
return fromXGrid + fromYGrid;
}
else { // Bottom right corner is white, like a chess board:
/*
XOXOX
1Y1Y1
XOXOX
*/
long fromXGrid = ((m-6)/2) * ((n-6)/2);
--n; --m;
long fromYGrid = ((m-6)/2) * ((n-6)/2);
return fromXGrid + fromYGrid;
}
}
public static void main(String[] args) throws Exception {
Scanner s = new Scanner(System.in);
while(true) {
int n = s.nextInt();
int m = s.nextInt();
int c = s.nextInt();
if(n == 0 && m == 0 && c == 0)
return;
System.out.println(gib(n, m, c));
}
}
}