Time limit per test
2 seconds
Memory limit per test
256 megabytes
Input
Standard Input
Output
Standard output
You are given a rectangular boardMLimit × limitNSquares. Also you are given an unlimited number of standard Domino pieces of 2 bytes × hour 1squares.
You are allowed to rotate the pieces. You are asked to place as your dominoes as possible on the board so as to meet the following conditions:
1. Each Domino completely covers two squares.
2. No two dominoes overlap.
3. 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 integersMAndN-
Board sizes in squares (1 ≤ halfMLimit ≤ limitNLimit ≤ limit 16 ).
Output
Output one number-the maximal number of dominoes, which can be placed.
Sample test (s) Input
2 4
Output
4
Input
3 3
Output
4
Problem solving Description: This question is greedy. Since N is not less than m, we should try to build bricks in n vertical direction, and finally handle a blank line.
#include <iostream>#include<cstdio>#include<cstring>#include<cmath>using namespace std;int main(){int m,n;int temp1,temp2;int sum;sum=0;scanf("%d %d",&m,&n);temp1=m/2;sum=temp1*n;temp2=m%2;if(temp2==1){sum+=n/2;}printf("%d\n",sum);return 0;}