当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1303:Byte Me!

题目描述
You are a dealer at The One, the first all-binary casino in Las Vegas. What makes The One special is that its blackjack tables don't use cards; they use bytes (an 8-bit sequence representing a number from 0 to 255) and nibbles (a 4-bit sequence representing a number from 0 to 15).

All day long, you play the house's hand against individual opponents. Of course, the casino owners know their statistics, and they have devised a strategy for you that gives gamblers just less than even odds.

Here are the rules of binary blackjack:

  1. The goal of the game is to be the player closest to 510 points without going over.
  2. Each player is dealt two bytes, one face up and one face down.
  3. The players then have the opportunity to take more bytes (by saying, "Byte Me!") or more nibbles (by saying, "Nibble Me!") until he reaches his limit of 4 hits or has more than 510 points showing.
  4. All hits are played face up.
  5. If a player goes over 510, he immediately busts and loses the hand.
  6. The dealer hits last.
  7. The dealer wins any ties (this includes a tie where everyone busts).

The rules for the dealer are (in order of precedence, where lower numbered rules override higher numbered ones):

  1. Never hit when it is certain that you've won by simply looking at your hand and what is showing of other people's hands.
  2. If your total is strictly less than 382 take a byte hit.
  3. If your total is less than or equal to 500 take a nibble hit.
  4. Take no hits
输入解释
Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets.

A single data set has 6 components:

  1. Start line : A single line, "START N", where N is the number of players playing this hand (not including the dealer). There will never be more than 10 non-dealer players, and the dealer never plays by himself.
  2. Dealer Line : A single line containing 2 binary strings of exactly eight digits separated by exactly one space. These two strings represent the two cards in the dealer's hand.
  3. Player Line : A single line containing N 8-digit binary strings, each separated from the others by a single space. These represent the face-up cards of all of the non-dealer players.
  4. Byte Line : A single line containing 4 8-digit binary strings, each separated from the others by a single space. These represent the next 4 bytes in the byte deck, in the order they will be drawn.
  5. Nibble Line : A single line containing 4 4-digit binary strings, each separated from the others by a single space. These represent the next 4 nibbles in the nibble deck, in the order they will be drawn.
  6. End line : A single line, "END".

Following the final data set will be a single line, "ENDOFINPUT".


Here are some other useful facts:

  • Oddly enough, each non-dealer player is always dealt a face-down card 11111111, value 255, but the dealer has no knowledge of this.
  • Players other than the dealer never hit (they aren't too bright).

输出解释
Calculate the actions taken by the dealer and how the dealer fares with the resulting hand.


For each data set, there will be exactly one output set, consisting of the following components:

  1. Hand Line : A single line, "HAND N", where N is the number of players playing this hand (not including the dealer).
  2. Dealer Hit List : A single line will be printed for each hit the dealer takes on his turn. For a byte hit, print a line "Byte me!", and for a nibble hit print, "Nibble me!"
  3. Outcome Line : A single line containing "Win!" if the dealer wins, "Bust!" if the dealer loses by busting, and "Lose!" if the dealer loses without busting.
输入样例
START 1
11111111 11111111
00000001
10101010 01010101 11110000 00001111
1010 0101 1100 0011
END
START 1
10111110 10111111 
11111110
00010010 10101010 01010101 11110000
0001 1010 1100 0011
END
START 8
11111111 00001000
00000000 00000001 00000010 00000011 00000100 00000101 00000110 00000111 
00010010 10101010 01010101 11110000
0001 1010 1100 0011
END
ENDOFINPUT
输出样例
HAND 1
Win!
HAND 1
Byte me!
Nibble me!
Nibble me!
Nibble me!
Lose!
HAND 8
Win!

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 South Central USA 2002

源链接: POJ-1303

最后修改于 2020-10-29T06:00:33+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 10000