You are very hungry and decide to visit a restaurant with a couple of friends. You want to order three dishes for the three of you. But, the chef serves you only if the total cost of the dishes selected by you is a multiple of the cost of exactly one of the dishes selected. You get lucky and you quickly selected 3 dishes satisfying the above criteria. What are the total number of possible ways to select the same? You have your laptop with you and menu containing 500 dishes is provided to you in excel format( You can use a random generator in excel for price between 1-100$(both included) ** Please note that No same dish can be selected

  • 6
    $\begingroup$ Is this a codechef problem? $\endgroup$ Oct 2, 2019 at 16:15

2 Answers 2


I don't think this is possible to exactly solve, but here is my attempt with probabilities, which leads to a complicated expression (which I have not quite worked out yet):

Let the price of one of the dishes be $\$x$, and the other two be $\$(x+y_1)$ and $\$(x-y_2)$. We have $$3x +y_1 - y_2 = nx$$
$$\implies 3 + {y_1 - y_2\over x} = n$$ $$\implies y_1-y_2 \bf{~is~a~ multiple~ of ~}$$ $$x.$$
So, given any meals of price $x$, choose any other meal of price $x+y_1$. The expected number of such meals is $5(100-x)$. Now, the multiples of $x$ above our range is $\left[{\frac{500}x}\right]$. These are our number of choices for $y_1 - y_2$. So, we may count the choices for $y_2$ given a choice from $y_1$ in our earlier calculation, take the product of the counts, and sum from $x = 1$ to $x = 100$.


Literally thousands of answers.

Dish1 costs (price1) 1
Dish2 and Dish3 cost (price2, price3) a prime number greater than 3 where price2 != price3.
If either price is 3, the other cannot be 2 or 5.


Not the answer you're looking for? Browse other questions tagged or ask your own question.