Byte Me!

Description

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:

The goal of the game is to be the player closest to 510 points without going over.
Each player is dealt two bytes, one face up and one face down.
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.
All hits are played face up.
If a player goes over 510, he immediately busts and loses the hand.
The dealer hits last.
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):

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.
If your total is strictly less than 382 take a byte hit.
If your total is less than or equal to 500 take a nibble hit.
Take no hits
Input

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:

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.
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.
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.
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.
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.
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).

Output

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:

Hand Line : A single line, "HAND N", where N is the number of players playing this hand (not including the dealer).
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!"
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.
Sample Input

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
Sample Output

HAND 1
Win!
HAND 1
Byte me!
Nibble me!
Nibble me!
Nibble me!
Lose!
HAND 8
Win!

http://blog.csdn.net/xiazdong/article/details/6929975

描述
你是一个经销商在第一,所有的二进制在拉斯维加斯赌场。是什么让一个特别的是21点不使用信用卡,他们用字节(一个8位序列代表一个数字从0到255)和轻咬(4比特序列代表一个数字从0到15)。
一整天,你房子的手对个人的对手。当然,赌场老板知道自己的统计数据,他们已经为你设计了一个战略,让赌徒甚至略低于几率。
这里是二进制21点的规则:
游戏,玩家的目标接近510点不了。
每个玩家处理两个字节,一个面对,一个面朝下。
然后,玩家有机会承担更大的字节(说,“字节我!”)或更轻咬(说:“咬我!”),直到他达到他的极限4达到或已超过510点。
所有被面对的演奏。
如果一个玩家超过510,他立即崩溃,失去了的手。
经销商支安打。
经销商赢得任何关系(这包括一个系,每个人都崩溃)。
经销商的规则(在优先顺序,较低的编号规则覆盖高编号的):
从未达到一定时,你已经赢了,只要看你的手,什么是显示别人的手。
如果你的总严格小于382字节。
如果你总小于或等于500咬击中。
不打
输入
这个问题将包括一个输入(非空)系列100数据集。每个数据集将根据以下格式的描述,和不会有空白行分隔数据集。
一个数据集有6个组件:
开始行:一行,“N”开始,其中N是玩这只手的玩家数量(不包括经销商)。永远不会有超过10 non-dealer球员,和经销商自己从来不玩。
经销商:一行包含2到底是八位数的二进制字符串由一个分隔空间。这两个字符串代表经销商手中的两张牌。
玩家:一行包含N八位二进制字符串,每个由一个空格分开。这些代表面朝上的纸牌的所有non-dealer球员。
字节:一行包含4 8位二进制字符串,每个由一个空格分开。这些代表下一个4字节的字节甲板,他们的顺序将它们分开。
咬线:一行包含4 4位二进制字符串,每个由一个空格分开。这些代表下一个4轻咬啃甲板,他们的顺序将它们分开。
结束行:一行,“结束”。
最后的数据集将后一行,“ENDOFINPUT”。
以下是一些有用的事实:
奇怪的是,每个non-dealer玩家总是处理面卡11111111,价值255,但是经销商没有这方面的知识。
玩家除了经销商从来没有达到(他们不是太亮)。
输出
计算的行动经销商和经销商票价如何产生的手。
对于每个数据集,将会有一个输出设置,包括以下组件:
线:一行,“N”手,其中N是玩这只手的玩家数量(不包括经销商)。
经销商名单:一行将打印每个经销商就轮到他了。为一个字节,打印线”字节我!”,咬点击打印,“咬我!”
结果:一行包含“赢!“如果经销商获胜,”破产!“如果经销商失去通过拆散,和“失去!“如果经销商失去没有戳穿。
样例输入
开始1
11111111 11111111
00000001
10101010 01010101 10101010 00001111
1010 0101 1100 0011
结束
开始1
10111110 10111111
11111110
00010010 10101010 00010010 11110000
0001 1010 1100 0011
结束
开始8
11111111 00001000
00000000 00000001 00000010 00000011 00000010 00000001 00000000 00000111
00010010 10101010 00010010 11110000
0001 1010 1100 0011
结束
ENDOFINPUT
样例输出
手1
赢了!
手1
字节我!
咬我!
咬我!
咬我!
失去!
手8
赢了!