Question: Lucky Gifts
"Planet Kids Entertainment Fair" is back to delight kids and parents. The Fair will have non-stop entertainment with an extravaganza of games, exciting rides, sports, art & crafts, role-plays, inspiring competitions, prizes & gifts, and yummy food.
Few lucky attendees at the Fair will be given a pack of candies as a lucky gift and the show coordinator has assigned you the task for choosing the number of attendees who will receive the pack of candies. There are 'N' candies available and you need to decide how many candies to place in each pack. Each pack must contain the same number of candies. You should choose an integer A between 1 and N, inclusive, and place exactly A candies into each pack. You should make as many packs as possible but since you enjoy eating candies very much, you eat the remaining candies.
Write a program that will calculate the maximum number of candies per pack that can be made with 'N' candies so that you can also maximise the number of candies that you can eat.
Input Format:
The first and only line of input contains an integer N.
Output Format:
Output a single line that gives the maximum number of candy packs that can be made with 'N' candies.
Refer sample input and output for formatting specifications.
Sample Input 1:
2
Sample Output 1:
2
Sample Input 2:
5
Sample Output 2:
3
SOLUTION:
#include<stdio.h>
int main()
{
int a,b;
scanf("%d",&a);
b=(a/2)+1;
printf("%d",b);
return 0;
}
I made a not too bad endeavor to get imply about how I could show substance of this blog. I should state, not much intense yet rather I surrendered each one of my weapons not long after subsequent to understanding it. personalized gifts
ReplyDeletecan i know the explanation for this sum
ReplyDeleteCode in c++
ReplyDelete#include
Deleteusing namespace std;
int main(){
int total_candy;
size=(total_candy/2)+1;
cout<<size;
return 0;
}
Code in python
ReplyDeletea=int(input())
Deleteb=(a/2)+1
print(b)