Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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 << "
";
	}
};
int main()
{
	solution ss;

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

	return 0;
}
Source by www.codechef.com #
 
PREVIOUS NEXT
Tagged: #Buy #Get #Free #codechef #solution
ADD COMMENT
Topic
Name
7+6 =