Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
int n, m;
while(t--){
cin>>n>>m;
int lights;
lights = (n*m)%2 == 0 ? ((n * m) / 2) : (((n * m) / 2) + 1);
cout<<lights<<endl;
}
}
Copy The Code &
Try With Live Editor
Input
5
1 1
1 3
2 2
3 3
5 3
1 1
1 3
2 2
3 3
5 3
Output
1
2
2
5
8
2
2
5
8
Demonstration
Codeforcess solution 1358-A A. Park Lighting ,C++, Java, Js and Python,1358-A,Codeforcess solution