Solution for Codechef MUFFINS3 | Packaging Cupcakes

Hello Programmers,

The solution for codechef Packaging Cupcakes problem is given below.

Problem Link:- https://www.codechef.com/problems/MUFFINS3

/*
*   Author:- Rahul Malhotra
*   Source:- Programming Vidya
*   Description:- Solution for Codechef Packaging Cupcakes problem
*   Problem Link:- https://www.codechef.com/problems/MUFFINS3
*   Website:- www.programmingvidya.com
*/

#include<iostream>
using namespace std;

int main()
{
    // * Initializing variables
    int numberOfTestCases, n;

    // * Accepting the number of test cases
    cin>>numberOfTestCases;

    // * Executing each test case one by one
    while(numberOfTestCases--)
    {
        // * Accepting the number of cupcakes for the current test case
        cin>>n;

        // * Package size that will maximize the number of leftover cupcakes
        cout<<(n/2)+1<<endl;
    }
    return 0;
}

Happy Coding..!!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s