Given the range of cost from lowCost to upCost and range of quantity from lowQuant to upQuant, find if it is possible to get a given ration ratio r where , and lowCost <= cost <= upCost and lowQuant <= quantity <= upQuant.
Input : lowCost = 1, upCost = 10, lowQuant = 2, upQuant = 8 r = 3 Output : Yes Explanation: cost / quantity = 6 / 2 = 3 where cost is in [1, 10] and quantity is in [2, 8] Input : lowCost = 14, upCost = 30, lowQuant = 5, upQuant = 12 r = 9 Output : No
Approach: From the given formula, following equation can be easily deduced: . From this equation, logic can be easily deduced. Check the product of every value of quantity with r and if any value of the product lies between lowCost and upCost, then answer is Yes otherwise it is No.
Below is the implementation of above approach:
- Find the number which when added to the given ratio a : b, the ratio changes to c : d
- Find the sum of the costs of all possible arrangements of the cells
- Choose points from two ranges such that no point lies in both the ranges
- Find nth Fibonacci number using Golden ratio
- Program to find the common ratio of three numbers
- Ratio of mth and nth terms of an A. P. with given ratio of sums
- Program to find the count of coins of each type from the given ratio
- Find amount to be added to achieve target ratio in a given mixture
- Find the ratio of number of elements in two Arrays from their individual and combined average
- Sum of two numbers if the original ratio and new ratio obtained by adding a given number to each number is given
- Find speed of man from speed of stream and ratio of time with up and down streams
- P - smooth numbers in given ranges
- Number of intersections between two ranges
- Count Primes in Ranges
- Queries for maximum difference between prime numbers in given ranges
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : jit_t