-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVa00278.java
More file actions
39 lines (37 loc) · 757 Bytes
/
UVa00278.java
File metadata and controls
39 lines (37 loc) · 757 Bytes
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
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Main
{
static PrintStream out = System.out;
static final int INF = 1000000000;
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int N = in.nextInt();
while (N-- > 0)
{
String piece = in.next();
int m = in.nextInt();
int n = in.nextInt();
int ans = 0;
int lg = Math.max(m, n);
int sm = Math.min(m, n);
switch (piece)
{
case "k":
ans = (((m + 1) / 2) * ((n + 1) / 2)) + ((m / 2) * (n / 2));
break;
case "r": case "Q":
ans = sm;
break;
case "K":
ans = (lg / 2 + lg % 2) * (sm / 2 + sm % 2);
break;
}
out.println(ans);
}
}
}