A. Domino Piling

Source: Internet
Author: User
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;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.