Animal Lottery
Time limit2sMemory limit512 MB
Given a bet value, a chosen number, and a drawn number, compute the largest prize based on how many trailing digits match.
- Level
Easy3 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
In a faraway country, people are hooked on a very simple betting game. The game is played with numbers and is called jogo do bicho (the animal game). The name comes from the fact that the numbers are split into 25 groups by the value of their last two digits (tens and units), and each group is named after an animal. The first group (donkey) is made of the numbers 01, 02, 03 and 04; the second group (eagle) is made of 05, 06, 07 and 08; and so on, up to the last group, which holds 97, 98, 99 and 00.
The rules are simple. When placing a bet, the player picks a bet value and a number (). Every day a number () is drawn in the main square of the city. Each player's prize is computed as follows:
- If and have the same last four digits (thousands, hundreds, tens and units), the player receives (for example, and ).
- If and have the same last three digits (hundreds, tens and units), the player receives (for example, and ).
- If and have the same last two digits (tens and units), the player receives (for example, and ).
- If the last two digits of and fall in the same group, that is, the same animal, the player receives (for example, and ).
- If none of the cases above applies, the player receives nothing.
The prize a player receives is, of course, the largest one possible under the rules above. Prizes do not accumulate, however, so only one of the criteria above is applied when computing the prize. If a number or with fewer than four digits is bet or drawn, assume it is padded with leading zeros to four digits; for example, 17 corresponds to 0017.
Given the bet value, the number chosen by the player, and the drawn number, write a program that computes the prize the player receives.
Input
The input contains several test cases. Each test case is a single line holding a real number with two decimal places and two integers and . They are, in order, the bet value (), the number chosen for the bet (), and the drawn number ().
The end of the input is marked by the line 0 0 0, where . Do not process that line.
Output
For each test case, print one line with the prize for that bet, written with exactly two decimal places. The prize can always be written exactly in this form.