-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathP278.cpp
53 lines (47 loc) · 839 Bytes
/
P278.cpp
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
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <stdio.h>
using namespace std;
void handleRook(int w, int h) {
if(w < h)
cout << w << endl;
else
cout << h << endl;
}
void handleKnight(int w, int h) {
int ret = ((w+1)/2)*((h+1)/2) + (w/2)*(h/2);
cout << ret << endl;
}
void handleQueen(int w, int h) {
if(w < h)
cout << w << endl;
else
cout << h << endl;
}
void handleKing(int w, int h) {
++w;
++h;
cout << (w/2)*(h/2) << endl;
}
int main() {
int cases; cin >> cases;
for(int cas = 0; cas < cases; ++cas) {
char unit;
int w, h;
cin >> unit >> w >> h;
switch(unit) {
case 'r':
handleRook(w, h);
break;
case 'k':
handleKnight(w, h);
break;
case 'Q':
handleQueen(w, h);
break;
case 'K':
handleKing(w, h);
break;
}
}
return 0;
}