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..!!

Leave a comment