Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define endl '\n'
- #define sz(x) int(x.size())
- #define all(x) x.begin(), x.end()
- int main() {
- ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
- int n, m;
- while (scanf("%d %d", &n, &m), n || m) {
- int ans = (((n + 1) / 2) * ((m + 1) / 2)) + ((n / 2) * (m / 2));
- if (min(n, m) == 1) ans = max(ans, max(n, m));
- else if (min(n, m) == 2) ans = max(ans, ((max(n, m) + 2) / 4) * 4 + 2 * (max(n, m) % 4 == 1));
- printf("%d knights may be placed on a %d row %d column board.\n", ans, n, m);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement