adplus-dvertising

Fill The Grid CodeChef Solution

We Are Discuss About CODECHEF SOLUTION

Fill The Grid CodeChef Solution

Fill The Grid CodeChef Solution

You have a grid with¬†NN¬†rows and¬†MM¬†columns. You have two types of tiles ‚ÄĒ one of dimensions¬†2√ó22√ó2¬†and the other of dimensions¬†1√ó11√ó1. You want to cover the grid using these two types of tiles in such a way that:

  • Each cell of the grid is covered by exactly one tile; and
  • The number of¬†1√ó11√ó1¬†tiles used is minimized.

Find the minimum number of 1×11×1 tiles you have to use to fill the grid.

Input Format

  • The first line of input will contain a single integer¬†TT, denoting the number of test cases.
  • Each test case consists of a single line containing two space-separated integers¬†N,MN,M.

Fill The Grid CodeChef Solution

Output Format

For each test case, print on a new line the minimum number of 1×11×1 tiles needed to fill the grid.

Constraints

  • 1‚ȧT‚ȧ1041‚ȧT‚ȧ104
  • 1‚ȧN,M‚ȧ1041‚ȧN,M‚ȧ104

Sample Input 1 

4
1 1
4 5
6 8
3 2

Sample Output 1 

1
4
0
2

Explanation

Fill The Grid CodeChef Solution

Test case 11: There is only one square in the grid, and it must be filled with a single 1×11×1 tile.

Test case 22: One way of tiling the grid using 1×11×1 tiles exactly 44 times is as follows:

sample 2

Test case 33: One way of tiling the grid using no 1×11×1 tiles is as follows:

sample 3

Test case 44: One way of tiling the grid using 1×11×1 tiles exactly twice is:

sample 4

SOLUTION

Fill The Grid CodeChef Solution

SOLUTION

Fill The Grid CodeChef Solution

SOLUTION

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE

Related Posts

One thought on “Fill The Grid CodeChef Solution

  1. Howdy! This is my first visit to your blog! We are a group of volunteers and starting a new project in a community in the same niche. Your blog provided us valuable information to work on. You have done a wonderful job!|

Leave a Reply

Your email address will not be published.