Menu

COJ 1839 – A Funny Task

January 1, 2017 - COJ

This task may sound a little weird, because even if we have even number of oranges, after passing the first guard we will be down to odd number and we might have a little confusion when giving the half and 3 more, but you just skip this and write the answer as it should be ,   (((N+3)*2+3)*2+3)*2 . 

Language: C++

#include <iostream>
using namespace std;

int main() 
{
	int t,k,n;
	cin>>t;
	for(k=1;k<=t;k++)
	{
		cin>>n;
		cout<< (((n+3)*2+3)*2+3)*2<<endl;
	}
	// your code goes here
	return 0;
}

(58)

It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on VK

Author of this post : safrastyan

Leave a Reply

Your email address will not be published. Required fields are marked *