Skip to content

Instantly share code, notes, and snippets.

@MahraibFatima
Created January 5, 2025 15:47
Show Gist options
  • Save MahraibFatima/040b8f1c8bf1ffe7b83177290c34b97f to your computer and use it in GitHub Desktop.
Save MahraibFatima/040b8f1c8bf1ffe7b83177290c34b97f to your computer and use it in GitHub Desktop.
151A

Problem Statement

This winter is so cold in Nvodsk! A group of n friends decided to buy k bottles of a soft drink called "Take-It-Light" to warm up a bit. Each bottle has l milliliters of the drink. Also they bought c limes and cut each of them into d slices. After that they found p grams of salt.

To make a toast, each friend needs nl milliliters of the drink, a slice of lime and np grams of salt. The friends want to make as many toasts as they can, provided they all drink the same amount. How many toasts can each friend make?


Input: The first and only line contains positive integers n, k, l, c, d, p, nl, np, not exceeding 1000 and no less than 1. The numbers are separated by exactly one space.


Output: Print a single integer — the number of toasts each friend can make.


#include <iostream>
#include <string>
using namespace std;

int main()
{
 int no_of_frnd, no_of_bottles, milliliter, no_of_limes, no_of_slice_cut, no_of_gram_salt, no_of_milliliter_required, no_of_gram_salt_required, slice=1;
 cin >> no_of_frnd>> no_of_bottles >> milliliter >> no_of_limes >> no_of_slice_cut >> no_of_gram_salt >> no_of_milliliter_required >> no_of_gram_salt_required;
 //cout<< no_of_frnd<< no_of_bottles<< milliliter<< no_of_limes<< no_of_slice_cut<< no_of_gram_salt<< no_of_milliliter_required<< no_of_gram_salt_required;
 
 //Required for everyone
 int drink_for_one = no_of_frnd * no_of_milliliter_required;
 int slice_for_one = no_of_frnd * slice;
 int salt_for_one = no_of_frnd * no_of_gram_salt_required;
 
 //stuff we have
 int total_milliliter = no_of_bottles * milliliter;
 int total_slices = no_of_limes * no_of_slice_cut;
 int total_salt = no_of_gram_salt;
 
 //variables for storing input
 int cnt_little=0, cnt_slice=0, cnt_salt=0;
 
 cnt_little = total_milliliter/drink_for_one;
 cnt_slice = total_slices/slice_for_one;
 cnt_salt = total_salt/salt_for_one;
    
 cout << std::min(cnt_little, std::min(cnt_slice, cnt_salt));
 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment