50A. Domino piling
- time limit per test2 seconds
- memory limit per test256 megabytes
- inputstandard input
- outputstandard output
You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:
给你一块M × N个正方形的长方形板。此外,您还可以获得无限数量的标准domino块2 × 1平方米。你可以旋转棋子。您被要求在黑板上放置尽可能多的多米诺骨牌,以满足以下条件:
- Each domino completely covers two squares.
- 每个多米诺骨牌完全覆盖两个正方形。
- No two dominoes overlap.
- 没有两个多米诺骨牌重叠。
- Each domino lies entirely inside the board. It is allowed to touch the edges of the board.
- 每个多米诺骨牌都完全位于董事会内部。允许触摸板的边缘。
Find the maximum number of dominoes, which can be placed under these restrictions.
找出可以放置在这些限制下的多米诺骨牌的最大数量。
Input
In a single line you are given two integers M and N — board sizes in squares (1 ≤ M ≤ N ≤ 16).
在一行中,你会得到两个整数M和N——电路板大小的平方(1 ≤ M ≤ N ≤ 16).
Output
Output one number — the maximal number of dominoes, which can be placed.
输出一个数字——可以放置的多米诺骨牌的最大数量。
Examples
input1
2 4
output1
4
input2
3 3
output2
4
Solution
直接m*n/2取商即可
Code
#include <iostream>
using namespace std;
//50A. Domino piling
int main() {
int m,n = 0;//n:m × n个正方形的长方形板
cin >> m >> n;
cout << m * n /2 << endl;
return 0;
}