ICS Contest 1 Problem 5 - Minecraft SMP

View as PDF

Submit solution


Points: 5
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
Java

Iaminnocent4298 is on a Minecraft SMP! He has a shop that sells a specific item, but the only way he can obtain this item is through villager trading. Unfortunately, he only has two villagers, which sell the item at a rate of 1 emerald for A or B items, depending on which villager he uses. Thankfully, he has an automatic iron farm that provides him with essentially limitless emeralds. Since he doesn't know how many of this item any particular member would need, he wants to find the maxmimum number of items he cannot obtain by solely purchasing from the villagers.

Constraints

2 \leq A,B \leq 1000

Input Specifications

The first and only line of input will contain the integers A,B.

Output Specifications

Output the maximum number of items he cannot obtain exactly just from trading. If there is no maximum, output ruh roh :c.

Sample Input 1

3 4

Sample Output 1

5

Explanation for Sample Output 1

It is impossible to purchase exactly 5 items from the two villagers. It can be shown that 5 is the maximum number that can't be obtained.

Sample Input 2

4 6

Sample Output 2

ruh roh :c

Explanation for Sample Output 2

It is impossible to purchase any odd number of items. Since there is no largest odd number, there exists no maximum.


Comments

There are no comments at the moment.