Problem: https://www.codechef.com/PBK12020/problems/ITGUY17
DIFFICULTY:
EASY.
PROBLEM:
Chef has N laddus of K sweetness each. Chef wants to eat all laddus, but Chef is restricted with the given condition that he must not eat two adjacent laddus. Chef starts calculating the maximum sweetness that he will get from the laddus. Find the maximum sweetness that chef gets at the end of all calculations.
Program:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
ll t,n,k;
cin >> t;
while (t--) {
cin >> n >> k;
if (n % 2 == 0) {
cout << (n / 2) * k << "\n";
}
else {
cout << (n / 2 + 1) * k << "\n";
}
}
return 0;
}