BROUL - Babylonian Roulette

no tags 

People of Babylon were devoted to chance games and one of the most popular was a special kind of roulette. Recently, some old Babylonian tablets were found. They described details of the roulette game.

In modern terms, the rules of the game were as follows:

  • Roulette’s compartments had only six labels: -1, -2, -3, 1, 2, 3.
  • The game was played by turns, during a day. Turns were numerated 0, 1, 2, ...
  • Players could win or lose a multiple of the bet, a quantity of money that was constant along the day.
  • At turn t there was an amount of money Pt, called the pot.
  • At the start, there was an initial amount of money P0 in the pot.
  • P0 and the bet were positive numbers arbitrarily defined by the King.
  • In a turn, a player turned the roulette. A player could not play more than once in a day. Depending on the compartment where the ball came to rest, the player won (or lose, if the value was negative) an amount wt = L * bet of money, where L corresponded to the compartment’s label.
  • The won money was taken from the pot (or put in it if the player lose), i.e. the value of the pot in a given turn was determined by Pt+1 = Pt + wt.
  • If as a result of the last rule Pt+1 was a negative number the winner won only the maximum multiple of the bet that he could win without making a negative pot.
  • If at some turn the pot was less than the bet, the game was ended for that day. If that was not the case the game continued till sunset.

Beside the tablets that explained the rules some other tablets were found. These had lines with three numbers. Archaeologists conjecture that each of these lines were part of a kind of accountability system for the game, where numbers represented, for a given day, the value of the pot at the beginning, the bet and the value of the pot at the end.

For example, a line with the numbers 10000 1500 11500 could mean that there was only one turn where the player won with label 1. Another possibility is that there were three turns with results 2, 1 and -2.

On the other hand, there were found other tablets with triplets of numbers that seem like the above described that, however, cannot represent results of a game day. There is no hypothesis of what they are.

Archaeologists want to validate their hypothesis analyzing batches of tablets with triplets. They want to estimate the number of people that played in a day. To begin, they want to establish, for each triplet of numbers in a tablet that could represent a result of a game day, the minimal number of players that played that day. In the above example the answer to this question is 1. Tablets that cannot represent results should be identified. You are hired to help with this task.

Input

The input file contains several test cases, each one of them in a separate line. Each test case is a triplet of non negative integers, indicating the initial pot, the bet and the final pot for a day.

Each of the input numbers is less than 108. The initial pot and the bet are greater than 0.

A line with a triplet of 0’s denotes the end of the input.

Output

Output texts for each input case are presented in the same order that input is read. For each test case the answer must be a printed line.

If the test case cannot represent the result of a game day, the output line has the words No accounting tablet. In other case, the printed answer is one positive integer number telling the minimal number of players that could turn the roulette for the day corresponding to the annotations.

Example

Input:
10000 1000 22000
24 13 2
5100 700 200
54 16 158
360 6 72
25 10 5
0 0 0

Output:
4
No accounting tablet
3
No accounting tablet
16
1

hide comments
susiconfusi: 2016-11-30 08:47:12

The last rule of the game, "If at some turn...", confused me a bit. Perhaps "at" could be replaced by "after".

alampata: 2013-09-22 20:00:46

<snip>
whats wrong with this code?

Last edit: 2022-07-31 10:50:59
Simón Murillo Gómez: 2012-08-03 02:22:48

Excellent Adhoc :)

saket diwakar: 2012-01-26 10:52:34

veryyyy easy !!!

rishabh: 2012-01-10 14:30:46

easy!!
just read the problem carefully

Nitin kaushik: 2011-07-01 18:19:24

Please someone explain me the output of 3 4 7

:D: 2010-07-28 11:21:12

Very easy problem! If you are a beginner, you should give it a shot.

Last edit: 2010-07-28 11:21:34
Luke Pebody: 2010-03-02 14:16:32

Accepted! I thought this would be:

2
No accounting tablet
No accounting tablet

Amr Mesbah: 2010-02-10 01:34:58

@ Linguo :

0
0
1

Luke Pebody: 2010-01-07 12:57:18

Can someone confirm what the answer should be for input "3 1 3\n3 4 3\n3 4 7\n" ?


Added by:Camilo Andrés Varela León
Date:2006-10-25
Time limit:0.305s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:XX Colombian National Programming ACM 2006