Sunday 12 November 2017

Code Challenge Solutions 3

1. Mahirl and Educational Fair


To make her Event Management company “Amphi Events and Decors” popular among the younger generation, Mahirl planned to conduct “The Great India Education Fair’. This Fair has proved to be a strong and cost-effective marketing platform for the Universities, Colleges, Schools and Education Institutions to reach out very cost-effectively to a larger number of parents and students.

              
There are many popular magazines that review these kinds of educational fairs and rate them.
They rate the fair as “Good” if the total number of people attending the fair is greater than 7000.
They rate the fair as “Outstanding” if both the number of parents attending the fair and the number of students attending the fair is at least 5000. However, if the number of students attending the fair is at least double the number of parents attending the fair, they rate the fair as “Great”.
If the total number of people attending the fair is less than 7001, they rate the fair as “Bad”.
Can you please help them in rating the fair?
Input Format:
Input consists of integers. The first integer corresponds to the number of parents who have attended the fair. The second integer corresponds to the number of students who have attended the fair.
Output Format:
The output consists of a string --- “Bad” or “Good” or “Outstanding” or “Great” or “Invalid Input”.
If any of the 2 input integers are negative, print “Invalid Input”.
Sample Input :
6000
5600
Sample Output :
Outstanding


Program:

#include<stdio.h>
int main()
{
int s,p;
scanf("%d%d",&p,&s);
if((s>=0)&&(p>=0))
{
if(s>=(2*p))
printf("Great");
else if(s>=5000&&p>=5000)
printf("Outstanding");
else if((p+s)>=7000)
printf("Good");
else
printf("Bad");
}
else
printf("Invalid Input");
return 0;
}


2. Watermelon Problem

[A variation of Code Forces Problem]

 
One hot summer day Peter and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that, the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.
 
Peter and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs the even number of kilos, at the same time it is not obligatory that the parts are equal. But the difference between the 2 parts should be minimal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out if they can divide the watermelon in the way they want. For sure, each of them should get a part of the positive weight.
 
Input Format
The first (and the only) input line contains integer number w (1 = w = 100) — the weight of the watermelon bought by the boys.
 
Output Format
If the input value is not within the range, print "Invalid Input".
In the first line of the output, print YES, if the boys can divide the watermelon into two parts, each of them weighing an even number of kilos; and NO in the opposite case.
If the first line of the output is YES, the next line of the output consists of 2 integers separated by a space. In case of distinct integers, the smallest number should appear first.
 
Sample Input 1
8
 
Sample Output 1
YES
4 4
 
Sample Input 2
11
 
Sample Output 2
NO
 
Sample Input 3
124
 
Sample Output 3
Invalid Input


Program:

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int w,c;
    scanf("%d",&w);
    if((w>=1)&&(w<=100))
    {
        if(w%4==0)
        {

            c=w/2;
            printf("YES");
            printf("\n%d%d",c,c);
        }
        else if(w%2==0)
        {
            c=w/2;
            printf("YES");
            printf("\n%d%d",c+1,c-1);
        }
        else{printf("NO");}
    }
    else
    {
      printf("Invalid Input\n");
    }

    return 0;
}



Code Challenge Solutions 1:

Code Challenge Solutions 2

5 comments:

  1. i want water melon problem in python

    ReplyDelete
  2. EventTitans is the hybrid event management software where Event Interactions made Ever Powerful and Highly Flexible.Satisfy all of your event management needs with EventTitans, the comprehensive and innovative hybrid solution.
    virtual event platform
    event management software
    event engagement platform
    event website builder
    online event ticketing
    virtual event platform
    event registration platforms

    ReplyDelete
  3. Thank you so much for sharing this information. RM Mileage is an Professional Conference Organizers in India that provides professional services at an affordable rate. Anyone interested in our services should contact us. Event Management Services | Corporate Event Planner | Event Management Companies | Indian DMC

    ReplyDelete
  4. Thank You for sharing this blog. I would like to share share this site for your information.

    Click Here: Corporate event planner in Chennai

    ReplyDelete
  5. Hey, nice informational Blog. Elevate your corporate offsite experience with Goa Offsite Event Management Company. We specialize in crafting unforgettable experiences tailored to your team's needs. From beachside retreats to adventure-filled excursions, we handle every detail, ensuring a seamless and memorable event. Let us know for more details.

    ReplyDelete