-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path696.cpp
More file actions
27 lines (26 loc) · 700 Bytes
/
696.cpp
File metadata and controls
27 lines (26 loc) · 700 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
#include <bits/stdc++.h>
using namespace std;
int main() {
int sum, j, k, l, n, m, mi, ma;
while (scanf("%d %d", &n, &m)) {
if (n == 0 && m == 0) return 0;
mi = min(n, m);
ma = max(n, m);
if (mi == 1) {
sum = ma;
} else if (mi == 2) {
if (ma % 2 != 0)
sum = ma + 1;
else {
j = ma / 2;
if (j % 2 == 0)
sum = ma;
else
sum = (j + 1) * 2;
}
} else
sum = ceil((n * m) / 2.0);
printf("%d knights may be placed on a %d row %d column board.\n", sum, n, m);
}
return 0;
}