Answers for "Buy 2 Get 1 Free codechef solution in c++"

C++
0

Buy 2 Get 1 Free codechef solution in c++

#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<climits>
#include<string>
using namespace std;

class solution
{
public:
	void solve()
	{
		int x, cnt , n, sum, total;
		cin >> x >> n;
		cnt = x / 3;
		sum = x * n;
		total = sum - (cnt * n);
		cout << total << "\n";
	}
};
int main()
{
	solution ss;

	int t;
	cin >> t;
	while (t--)
    {
		ss.solve();
	}

	return 0;
}
Posted by: Guest on March-19-2022

Browse Popular Code Answers by Language