Editorial for Mock CCC '19 Contest 1 J3 - Pusheen Eats Tuna Sashimi and Tuna Nigiri


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

For the first subtask, the answer is always YES, as one can always order N pieces of sashimi.

For the second subtask, it suffices to check if N is divisible by A, as any valid order that contains nigiri can be replaced with \frac{B}{A} pieces of sashimi.

For the third subtask, to check if a given amount is obtainable, we can use brute force to see if it is possible to spend N dollars buying exactly zero pieces of sashimi and spending everything else on nigiri, then buying exactly one piece of sashimi and using the rest on nigiri, and going up until we have exhausted our available budget only on sashimi.


Comments

There are no comments at the moment.