-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay_074.cpp
37 lines (32 loc) · 854 Bytes
/
Day_074.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
*Problem Statement: You have a grid with N rows and M columns. You have two types of tiles — one of dimensions
2×2 and the other of dimensions 1×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×1 tiles used is minimized.
Find the minimum number of 1×1 tiles you have to use to fill the grid.
*Author: Kunal Kathpal (https://github.com/kunal-2002)
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
cout<<"Enter number of test cases:\t";
ll T;
cin>>T;
while(T--){
int n, m;
cin>>n>>m;
if(n%2==0 && m%2==0){
cout<<0<<endl;
}
else if(n%2==0 && m%2!=0){
cout<<n<<endl;
}
else if(n%2!=0 && m%2==0){
cout<<m<<endl;
}
else{
cout<<n+m-1<<endl;
}
}
return 0;
}