Search
 
SCRIPT & CODE EXAMPLE
 

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;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ multiple if conditions 
Cpp :: solve diamond inheritance c++ 
Cpp :: how to calculate 2^7 in cpp code 
Cpp :: cocos2d c++ linux 
Cpp :: C++ References 
Cpp :: how to extract a bit from a byte in c++ 
Cpp :: how to find the sum of elements in a stack in cpp 
Cpp :: cudaMalloc 
Cpp :: left margin c++ 
Cpp :: Diamond pattren program in C++ 
Cpp :: friend class in c++ 
Cpp :: c++ string to const char* 
Cpp :: Targon lol 
Cpp :: print the elements of the array without using the [] notation in c++ 
Cpp :: erase in c++ 
Cpp :: how to read and write to a file in qt c++ 
Cpp :: bash script add another user 
Cpp :: c++ ignore_line 
Cpp :: c++ linker input and output 
Cpp :: how to complie c++ to spesific name using terminal 
Cpp :: for in c++ example 
Cpp :: deadlock detection in c++coding ninjas 
Cpp :: codeforces Pangram in c++ 
Cpp :: permutation and combination program in c++ 
Cpp :: 496. Next Greater Element I.cpp 
Cpp :: how to calculate the sum of primary diagonal matrix and secondary diagonal matrix using c++ 
Cpp :: passing a 2d array cpp 
Cpp :: c++ vector remove element by value 
Cpp :: vector to char array c++ 
Cpp :: frequency of characters in a string in c++ 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =