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
31 24 3
Sample Output
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