#B3943. Szm's Mahjong Victory

    ID: 11600 Type: Default 1000ms 256MiB

Szm's Mahjong Victory

Szm's Mahjong Victory

Szm, our beloved gamer, is playing a special version of Mahjong. In this game, the scoring is determined by the number of han (\(\text{番}\)) that a winning hand achieves. The rules are as follows:

  • Mangan (\(5\) han) gives a base score. For the dealer, the base score is \(12000\) points, while for non-dealers it is \(8000\) points. In this problem, Szm is the dealer.
  • For 6 to 7 han (called "\(\text{跳满}\)"), the winning score is \(1.5\) times the mangan score.
  • For 8 to 10 han ("\(\text{倍满}\)"), the winning score is \(2\) times the mangan score.
  • For 11 to 12 han ("\(\text{三倍满}\)"), the winning score is \(3\) times the mangan score.
  • For han between \(13x\) and \(13x+12\) (with \(x\) being a positive integer, referred to as "\(x\text{倍役满}\)"), the winning score is \(4x\) times the mangan score.

When Szm wins, she gains points equal to the winning score \(P\) while the current first-place player's score is decreased by \(P\). Thus, if the first-place player has \(A\) points and Szm has \(B\) points before the win, after winning she will have \(B+P\) and the first-place player's score will be \(A-P\). Szm becomes first if \(B+P \geq A-P\), which can be rearranged to \(P \geq \frac{A-B}{2}\).

Given that we are at the very last round (All Last) and that Szm (the dealer) is currently in second place, your task is to determine the minimum number of han (\(n\)) needed for her win so that her final score is not less than the first-place player's final score. Note that the only valid han counts are:

  • 5 for Mangan
  • A number between 6 and 7 for \(1.5\) Mangan
  • A number between 8 and 10 for \(2\) Mangan
  • A number between 11 and 12 for \(3\) Mangan
  • Any number \(n \geq 13\), where if \(n\) is in \([13x, 13x+12]\), the winning score is computed as \(4x\) Mangan.

Note: Although the rules are similar to those in real Mahjong, please strictly follow the rules stated here.

inputFormat

The input consists of two integers \(A\) and \(B\) given on one line, where:

  • \(A\) is the current score of the first-place player.
  • \(B\) is the current score of Szm (the dealer, currently in second place).

You may assume that \(A > B\).

outputFormat

Output a single integer representing the minimum number of han that Szm must achieve so that after winning, her score (\(B+P\)) is not less than the first-place player's score (\(A-P\)).

The winning score \(P\) is computed based on the han count \(n\) as follows (with base score \(12000\) for the dealer):

  • If \(n = 5\): \(P = 12000\).
  • If \(6 \leq n \leq 7\): \(P = 1.5 \times 12000 = 18000\).
  • If \(8 \leq n \leq 10\): \(P = 2 \times 12000 = 24000\).
  • If \(11 \leq n \leq 12\): \(P = 3 \times 12000 = 36000\).
  • If \(n \geq 13\) and \(n \in [13x, 13x+12]\) for some positive integer \(x\): \(P = 4x \times 12000\).

Szm wins if after the round:

\[ B + P \geq A - P \quad \Longleftrightarrow \quad P \geq \frac{A-B}{2}. \]</p>

sample

35000 22000
5