246 - 10-20-30

A simple solitaire card game called10-20-30 uses a standard deck of 52 playing cards in which suit is irrelevant.The value of a face card (king, queen, jack) is 10. The value of an ace is one.The value of each of the other cards is the face value of the card (2, 3, 4,etc.). Cards are dealt from the top of the deck. You begin by dealing out sevencards, left to right forming seven piles. After playing a card on the rightmostpile, the next pile upon which you play a card is the leftmost pile.

For each card placed on a pile, check thatpile to see if one of the following three card combinations totals 10, 20, or30.

 

                    1.            the first two and last one,

 

                    2.            the first one and the last two, or

 

                    3.            the last three cards.

 

If so, pick up the three cards and placethem on the bottom of the deck. For this problem, always check the pile in theorder just described. Collect the cards in the order they appear on the pileand put them at the bottom of the deck. Picking up three cards may expose threemore cards that can be picked up. If so, pick them up. Continue until no moresets of three can be picked up from the pile.

For example, suppose a pile contains 5 9 73 where the 5 is at the first card of the pile, and then a 6 is played. Thefirst two cards plus the last card (5 + 9 + 6) sum to 20. The new contents ofthe pile after picking up those three cards becomes 7 3. Also, the bottommostcard in the deck is now the 6, the card above it is the 9, and the one abovethe 9 is the 5.

If a queen were played instead of the six,5 + 9 + 10 = 24, and 5 + 3 + 10 = 18, but 7 + 3 + 10 = 20, so the last threecards would be picked up, leaving the pile as 5 9.

If a pile contains only three cards whenthe three sum to 10, 20, or 30, then the pile "disappears" when thecards are picked up. That is, subsequent play skips over the position that thenow-empty pile occupied. You win if all the piles disappear. You lose if youare unable to deal a card. It is also possible to have a draw if neither of theprevious two conditions ever occurs.

Write a program that will play games of10-20-30 given initial card decks as input.

Input

Each input set consists of a sequence of 52integers separated by spaces and/or ends of line. The integers represent cardvalues of the initial deck for that game. The first integer is the top card ofthe deck. Input is terminated by a single zero (0) following the last deck.

Output

For each input set, print whether theresult of the game is a win, loss, or a draw, and print the number of times acard is dealt before the game results can be determined. (A draw occurs as soonas the state of the game is repeated.) Use the format shown in the ``SampleOutput" section.

SampleInput

2 6 5 10 10 4 10 10 10 4 5 10 4 5 10 9 7 61 7 6 9 5 3 10 10 4 10 9 2 1

10 1 10 10 10 3 10 9 8 10 8 7 1 2 8 6 7 3 38 2

4 3 2 10 8 10 6 8 9 5 8 10 5 3 5 4 6 9 9 17 6 3 5 10 10 8 10 9 10 10 7

2 6 10 10 4 10 1 3 10 1 1 10 2 2 10 4 10 77 10

10 5 4 3 5 7 10 8 2 3 9 10 8 4 5 1 7 6 7 26 9 10 2 3 10 3 4 4 9 10 1 1

10  5 10 10 1 8 10 7 8 10 6 10 10 10 9 6 2 10 10

0

SampleOutput

Win : 66

Loss: 82

Draw: 73

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1-65535的全部端口列表如下: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值