1918A - Brick Wall - CodeForces Solution


constructive algorithms greedy implementation

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;

typedef long long ll;
typedef long double ld;
typedef pair<ll , ll> PII ;
typedef vector<bool> vb ;
typedef vector<ll> vi;
typedef vector<PII> vpi;
typedef vector<vector<ll>> vvi;
typedef vector<char> vc ;

const double EBS = 1e-9;
const double pi = 3.14159265358979 ;


#define Log(x) (31^__builtin_clz(x)) // Easily calculate log2 on GNU G++ compilers
#define logll(x) (63^__builtin_clzll(x))
#define popcount(i) __builtin_popcount(i)


#define mp make_pair

#define testCase ll t; cin >> t; while (t--)
#define fast  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(f, s, i) for (ll i = f; i < s; i++)
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
#define calunique(v)  disance(v.begin(),unique(v.begin(),v.end()));
#define el cout << "\n"
#define mb make_pair
#define pb push_back
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define all(v) v.begin(), v.end()
#define INF (ll) 1e9
#define INFLL (ll)1e18
#define debug cout << "___________________________________" << endl
#define left  ((p<<1) + 1)
#define right ((p<<1) + 2)
#define int ll


void solve(){
	int n , m ; cin >> n >> m ; 
	if(m % 2 == 0 ){
		cout << n*m / 2 << endl ; 
	}else{
		cout << (n*(m-1))/2  << endl ;
	}
}

int32_t main(){
	fast ;

	testCase{
		solve();
	}
	return 0;
}


Comments

Submit
0 Comments
More Questions

1552B - Running for Gold
994A - Fingerprints
1221C - Perfect Team
1709C - Recover an RBS
378A - Playing with Dice
248B - Chilly Willy
1709B - Also Try Minecraft
1418A - Buying Torches
131C - The World is a Theatre
1696A - NIT orz
1178D - Prime Graph
1711D - Rain
534A - Exam
1472A - Cards for Friends
315A - Sereja and Bottles
1697C - awoo's Favorite Problem
165A - Supercentral Point
1493A - Anti-knapsack
1493B - Planet Lapituletti
747B - Mammoth's Genome Decoding
1591C - Minimize Distance
1182B - Plus from Picture
1674B - Dictionary
1426C - Increase and Copy
520C - DNA Alignment
767A - Snacktower
1365A - Matrix Game
714B - Filya and Homework
31A - Worms Evolution
1691A - Beat The Odds