AOJ 589. Domino

Source: Internet
Author: User

time limit:1000 ms   case time limit:1000 ms   memory limit:64 MB
Tota L Submission:34   submission Accepted:12 description has a n*m grid, filled with some 2*1 dominoes. The
has the following rules:
1, each multi-meter must be completely covered two lattice
2, the domino cannot overlap
3, the Domino cannot exceed the grid boundary
4, can be rotated when the domino is placed, but not inclined to put the
ask the maximum number of dominoes can be used to cover the grid.

 

Input an integer t that indicates that there is a T group of test data. (1<=t<=3000)
The data entry format for each group is as follows:
for each set of data, enter the following:
Two integer n,m (1<=n,m<=100000)

 

output for each set of data, Outputs an integer that represents the maximum number of dominoes that can be placed

 

Sample Input
or Iginal transformed
31 24 3 

 

Sample Output
original transformed
144 

Greedy algorithm? Not count greedy algorithm bar ~ First vertical pendulum, as far as possible to fill (M*N/2), the rest of the position in a different direction as possible (N/2) * (m%2), add up can

1 /*2 By:ohyee3 Github:ohyee4 Email:[email protected]5 */6#include <cstdio>7#include <algorithm>8#include <cstring>9#include <cmath>Ten#include <string> One#include <iostream> A#include <vector> -#include <list> -#include <queue> the#include <stack> - using namespacestd; -   - #defineREP (n) for (int o=0;o<n;o++) +   -   + intMain () { A     intt,n,m; atscanf"%d",&T); -      while(t--) { -scanf"%d%d",&n,&m); -printf"%lld\n",(Long Long) (N/2)*(Long Long) m + (Long Long) -(n%2)*(Long Long) (M/2)); -     } in     return 0; -}

AOJ 589. Domino

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.