Codechef Problems: Popcorn Buying (POPCORN7)

 Problem Statement:

Chef has gone to see a movie. Chef has X (X100) rupees with him.

The movie ticket itself costs 100, and Chef must buy one movie ticket to be able to see the movie. With the money leftover, Chef will buy as many popcorn buckets as possible. A single popcorn bucket costs  rupees. How many popcorn buckets will Chef be able to buy?

Input Format

The first and only line of input contains a single integer X. 

Output Format

Output the number of popcorn buckets Chef can buy after paying for the movie ticket.

Constraints

100X250
  • 100 <= X <= 250

Solution: 

Given X: be the amount of money chef has (X >= 100)

part 1: Deduction of ticket money (ticket price : 50rs)

Y: Remaining Money 
Y = X - 100 

part 2: No of popcorn baskets he can buy 

Integer value of  (Y/50) because each popcorn basket costs 50rs. 

Code Solution: 

#include <bits/stdc++.h>
using namespace std;

int main() {
    int x; 
    cin >> x; 
    
    int y = (x - 100) / 50; 
    cout << y << endl; 
    return 0; 
}

Comments

Popular posts from this blog

Codechef Problems: Triangles (TRIANGLE7)

Codechef problems : New Year Resolution (NYRES)

Codechef Problems: Selling Sandwiches (SANDWSHOP)