# 扑克牌获胜概率的计算问题，用C语言来实现，具体怎么做的？

Problem Description

21 point,also named Black Jack, originated in France,has spread around the world.

21 point, a gambling game played by using poker,is also the only one which is able to win banker by using probability calculation.

--- Encyclopedia from good search

We define blackjack rules are as follows, which is different from the original rules slightly.

cards are as follows:

A 2 3 4 5 6 7 8 9 10 J Q K

A is as 1 point.

JQK are all as 10 points.

We assume that the casino prepared a lot of cards,that is, you can assume that the probability of getting each card is the same.

There are two players who were banker and Player.

They get two cards at first and can see the card each other.

Player operates first.

Every turn, he can bid or stop bidding.

If he bid, he can take a card from the deck.

Once the the points are over 21,he will lose at once,which is called "busting", otherwise he will bid until stopping bidding and turn to banker.

the rule of banker is the same as the player's.

If there is no "busting", the one who have higher points win.

If they have the same points,they get the tie.

Here is the task,we give you the cards that both people have gotten.

please judge whether the Player have more than 50% winning percentage,

if yes, output "YES", otherwise output,"NO".

Oh, yes, everyone is very smart.

Input

The first line of the input file contains an integer Test(Test<=100000), which indicates the number of test cases.

For each test case, there is a string with four characters. the first and the second char indicate the card of the player.and the others indicate the banker's.(we use ‘T’ instead of '10')

Output

For each case of data output "YES" or "NO", it indicates whether the Player have more than 50% winning percentage.

Sample Input

1

TTT9

Sample Output

YES

//it's clear that player will not bid, then the blanker has only 2/13 winning percentage.

- 点赞
- 写回答
- 关注问题
- 收藏
- 复制链接分享
- 邀请回答

*1*条回答

#### 相关推荐

- 回答 1 已采纳 Problem Description 21 point,also named Black Jack, originated in France,has spread around the world. 21 point, a gambling game played by using poker,is also the only one which is able to win banker by using probability calculation. --- Encyclopedia from good search We define blackjack rules are as follows, which is different from the original rules slightly. cards are as follows: A 2 3 4 5 6 7 8 9 10 J Q K A is as 1 point. JQK are all as 10 points. We assume that the casino prepared a lot of cards,that is, you can assume that the probability of getting each card is the same. There are two players who were banker and Player. They get two cards at first and can see the card each other. Player operates first. Every turn, he can bid or stop bidding. If he bid, he can take a card from the deck. Once the the points are over 21,he will lose at once,which is called "busting", otherwise he will bid until stopping bidding and turn to banker. the rule of banker is the same as the player's. If there is no "busting", the one who have higher points win. If they have the same points,they get the tie. Here is the task,we give you the cards that both people have gotten. please judge whether the Player have more than 50% winning percentage, if yes, output "YES", otherwise output,"NO". Oh, yes, everyone is very smart. Input The first line of the input file contains an integer Test(Test<=100000), which indicates the number of test cases. For each test case, there is a string with four characters. the first and the second char indicate the card of the player.and the others indicate the banker's.(we use ‘T’ instead of '10') Output For each case of data output "YES" or "NO", it indicates whether the Player have more than 50% winning percentage. Sample Input 1 TTT9 Sample Output YES //it's clear that player will not bid, then the blanker has only 2/13 winning percentage.
- 回答 1 已采纳 Problem Description 21 point,also named Black Jack, originated in France,has spread around the world. 21 point, a gambling game played by using poker,is also the only one which is able to win banker by using probability calculation. --- Encyclopedia from good search We define blackjack rules are as follows, which is different from the original rules slightly. cards are as follows: A 2 3 4 5 6 7 8 9 10 J Q K A is as 1 point. JQK are all as 10 points. We assume that the casino prepared a lot of cards,that is, you can assume that the probability of getting each card is the same. There are two players who were banker and Player. They get two cards at first and can see the card each other. Player operates first. Every turn, he can bid or stop bidding. If he bid, he can take a card from the deck. Once the the points are over 21,he will lose at once,which is called "busting", otherwise he will bid until stopping bidding and turn to banker. the rule of banker is the same as the player's. If there is no "busting", the one who have higher points win. If they have the same points,they get the tie. Here is the task,we give you the cards that both people have gotten. please judge whether the Player have more than 50% winning percentage, if yes, output "YES", otherwise output,"NO". Oh, yes, everyone is very smart. Input The first line of the input file contains an integer Test(Test<=100000), which indicates the number of test cases. For each test case, there is a string with four characters. the first and the second char indicate the card of the player.and the others indicate the banker's.(we use ‘T’ instead of '10') Output For each case of data output "YES" or "NO", it indicates whether the Player have more than 50% winning percentage. Sample Input 1 TTT9 Sample Output YES //it's clear that player will not bid, then the blanker has only 2/13 winning percentage.
- 回答 1 已采纳 Problem Description The magician shuffles a small pack of cards, holds it face down and performs the following procedure: 1.The top card is moved to the bottom of the pack. The new top card is dealt face up onto the table. It is the Ace of Spades. 2.Two cards are moved one at a time from the top to the bottom. The next card is dealt face up onto the table. It is the Two of Spades. 3.Three cards are moved one at a time… 4.This goes on until the nth and last card turns out to be the n of Spades. This impressive trick works if the magician knows how to arrange the cards beforehand (and knows how to give a false shuffle). Your program has to determine the initial order of the cards for a given number of cards, 1 ≤ n ≤ 13. Input On the first line of the input is a single positive integer, telling the number of test cases to follow. Each case consists of one line containing the integer n. Output For each test case, output a line with the correct permutation of the values 1 to n, space separated. The first number showing the top card of the pack, etc… Sample Input 2 4 5 Sample Output 2 1 4 3 3 1 4 5 2
- 回答 1 已采纳 Problem Description Bridge is a very complicated card game, and the bidding part is particularly difficult to master. The bidding is made even more difficult because players use different bidding conventions (meanings assigned to bids). In this problem, you are asked to write a program that suggests the first bid that should be made. The bidding conventions described below are simplified from those used by a certain person who shall remain nameless. A bridge hand consists of 13 cards. Each card has a suit (spades, hearts, diamonds, or clubs) and a rank (A, K, Q, J, T, 9, 8, 7, 6, 5, 4, 3, 2). Here, the letter T denotes the card whose rank is 10. Before making a bid, an experienced bridge player studies the number of high card points (hcp) in the hand, as well as the distribution (the number of cards in each suit). The hcp contributed by each card is completely determined by its rank as follows: Rank hcp A 4 K 3 Q 2 J 1 Others 0 For example, if the hand is: Spades: A, 2 Hearts: K, J, T, 9, 2 Diamonds: 3 Clubs: K, Q, 7, 4, 3 Then this hand has 13 hcp and a distribution of 5-5-2-1 (the distribution is usually listed in non-increasing order). A balanced distribution is any one of 4-3-3-3, 4-4-3-2, and 5-3-3-2. In bridge, an opening bid is either "pass" or consists of a level (1-7) and a trump suit. The trump suits are no trump, spades, hearts, diamonds, clubs ranked in decreasing order. Once a hand has been evaluated, the player applies the following list of (simplified) rules to determine the appropriate opening bid. In cases where multiple rules apply, the first one that applies should be used. An "x" in a distribution can be substituted with any non-negative number. Multiple "x"s in a distribution are not necessarily the same. 1. With at least 10 hcp and a y-x-x-x distribution (y >= 8), bid the suit with y cards at the 4 level. This is known as a preemptive bid. 2. With 10-13 hcp and a 7-x-x-x distribution, bid the suit with 7 cards at the 3-level. This is known as a preemptive bid. 3. With 8-9 hcp and a y-x-x-x distribution (y >= 7), bid the suit with y cards at the 2-level if the y-card suit is Spades or Hearts. This is known as a "weak-two" bid. 4. With 8-11 hcp and a 6-x-x-x distribution, in which Spades or Hearts is one of the 6-card suits, bid the higher rank suit at the 2 level. This is known as a "weak-two" bid. 5. With 11-15 hcp, a distribution of 4-4-4-1 or 5-4-4-0, and at least 4 spades, bid Diamonds at the 2 level. This is called the "Mini Roman Convention". 6. With 15-17 hcp and a balanced distribution, bid No Trump at the 1 level provided that at least 3 suits are "stopped." A suit is considered stopped if the suit contains at least one of the following: an A; a K and one other; a Q and two others; or a J and three others; 7. With 20-22 hcp and a balanced distribution, bid No Trump at the 2 level. 8.With at least 22 hcp, bid Clubs at the 2 level. 9. With 13-16 hcp: a. If there is a 5-card or longer suit in Spades or Hearts, bid it at the 1 level. If both bids are possible, bid the longer suit. If both suits have the same length, bid the higher ranking suit. b. Without a 5-card suit in Spades or Hearts, bid the longer of Diamonds or Clubs at the 1 level (whichever one has the most number of cards) . If there is a tie, bid the higher ranking suit. 10. With at least 17 hcp, bid the longest suit at the 1 level. If there is a tie, bid the lowest ranking suit. This is known as a "reverse". 11. If none of the rules above is applicable, bid Pass. In the example above, rule 9a applies and a bid of 1 Hearts should be made. Input The input consists of a number of cases. The bridge hand for each case is specified on one line, with a single space separating each of the 13 cards in the hand. Each card is given as a two-character string. The first letter is the suit (S, H, D, C) and the second character is the rank (A, K, Q, J, T, 9, 8, 7, 6, 5, 4, 3, 2). The end of input is terminated by end-of-file. Output For each case, print the hand number (starting from 1), followed by a colon and a space, and then the suggested bid on a single line (see below for the exact format). Each bid is either "Pass" or a level and a suit ("No Trump", "Spades", "Hearts", "Diamonds", "Clubs") separated by a single space. Sample Input SA S2 HK HJ HT H9 H2 D3 CK CQ C7 C4 C3 SK SQ HT H8 H4 CA CQ CT C5 DK DQ DJ D8 SA SK SQ S3 S2 HT D7 D9 CA CK CQ C7 C5 Sample Output Hand #1: 1 Hearts Hand #2: 1 No Trump Hand #3: 1 Clubs
- 回答 3 已采纳 为什么图中最后两个圆柱体积会有偏差![图片](https://img-ask.csdn.net/upload/201703/03/1488537913_161955.jpg)![图片](https://img-ask.csdn.net/upload/201703/03/1488538198_678928.jpg)
- 回答 2 已采纳 Problem Description The game of show hand is a card game. There are 52 cards and each card has a number and a suit. There are 13 different numbers called 2, 3, 4, 5, 6, 7, 8, 9, T (number 10), J (number 11), Q (number 12), K (number 13) and A (number 1 or 14), and there are 4 different suits called diamond (d), club (c), heart (h), and spade (s). A card can be represented as its number and its suit. For example, the card with number 10 and suit diamond is represented as “Td”, where “T” is for number 10 and “d” is for suit diamond. A hand is a combination of 5 cards. There are 9 different kinds of hands, sorted from best to worst, listed below. “Straight Flush”: 5 cards with consecutive numbers and the same suit. For example: Td Jd Qd Kd Ad. “4 of a Kind”: 4 cards with the same number and an arbitrary single card. For example: 2d 2c 2h 2s 3d. “Full House”: 3 cards with the same number and the remaining 2 cards have the same number. For example: 6d 6h 6s 7c 7s. “Flush”: 5 cards with the same suit but not consecutive numbers. For example: 2h 3h Qh Kh Ah. “Straight”: 5 cards with consecutive numbers but not the same suit. For example: As 2s 3s 4d 5d. “3 of a Kind”: 3 cards with the same number and the remaining 2 cards have different numbers. For example: Td Tc Ts 9s As. “2 Pairs”: 2 pairs of cards with the same number and the remaining card has a different number. For example: 3h 3s 6c 6h 4h. “1 Pair”: 2 cards with the same number and the remaining 3 cards have different numbers. For example: 4d 4c 2c 5d Ac. “High Card”: 5 cards with different, not consecutive numbers and not the same suits. For example: 2c 3d 8c 9h Ah. There are 2 players in the game of five-round show hand. When the game starts, each player will get 25 cards from the dealer. Then, for each round, each player shows a hand by choosing 5 cards from the cards he gets, and two players compare the hands they showed. The player who shows a better kind of hand wins the game. If they show the same kind of hands, they discard the cards they have shown and proceed to the next round. There are at most 5 rounds in a game. If they show the same kind of hands in all of the 5 rounds, the game ends in a tie. Both players play optimally. Your task is to find out the winner and the kind of hands he shows. Input The first line is the number of test cases up to 600. For each test case, there are two lines. The first line is the 25 cards player 1 gets, and the second line is the 25 cards player 2 gets. It is guaranteed that all the 50 cards are different. Output For each test case, output a line containing the winner and the kind of hands he shows. If the game ends in a tie,output “Tie” and the kind of hands both player show. Sample Input 3 2d 2h 3d 3c 4d 4s 5d 6h 7d 7c 8d 8c 9d 9s Td Tc Ts Th Jh Js Qd Qh Kc As Ad 2c 2s 3h 3s 4c 4h 5c 5h 5s 6d 6c 6s 7h 7s 8s 8h 9c 9h Jd Jc Qc Qs Kd Ac Ah 2s 3d 3c 3s 3h 4s 4h 5c 5s 6s 6h 7s 7h 8c 8s Td Th Js Jh Qs Qh Kc Kh Ad As 2d 2h 4d 4c 5d 5h 6d 6c 7d 7c 8d 8h 9d 9c 9s 9h Tc Ts Jd Jc Qd Kd Ks Ac Ah 2d 3d 4d 6d 7d 8d 9d Jd Qd Kd Ad 2c 3c 4c 6c 7c 8c 9c Jc Qc Kc Ac 5h 5s Th 2h 3h 4h 6h 7h 8h 9h Jh Qh Kh Ah 2s 3s 4s 6s 7s 8s 9s Js Qs Ks As 5d Td Tc Sample Output Player 1, Straight Flush Player 2, Straight Flush, 4 of a Kind, Flush, Straight, 1 Pair Tie, Flush, Flush, Flush, Flush, 2 Pairs
- 回答 1 已采纳 Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rules are simple. The players sit on opposite sides of a table, facing each other. Each player gets k cards from the deck and, after looking at them, places the cards face down in a row on the table. Adam’s cards are numbered from 1 to k from his left, and Eve’s cards are numbered 1 to k from her right (so Eve’s i:th card is opposite Adam’s i:th card). The cards are turned face up, and points are awarded as follows (for each i ∈ {1, . . . , k}): If Adam’s i:th card beats Eve’s i:th card, then Adam gets one point. If Eve’s i:th card beats Adam’s i:th card, then Eve gets one point. A card with higher value always beats a card with a lower value: a three beats a two, a four beats a three and a two, etc. An ace beats every card except (possibly) another ace. If the two i:th cards have the same value, then the suit determines who wins: hearts beats all other suits, spades beats all suits except hearts, diamond beats only clubs, and clubs does not beat any suit. For example, the ten of spades beats the ten of diamonds but not the Jack of clubs. This ought to be a game of chance, but lately Eve is winning most of the time, and the reason is that she has started to use marked cards. In other words, she knows which cards Adam has on the table before he turns them face up. Using this information she orders her own cards so that she gets as many points as possible. Your task is to, given Adam’s and Eve’s cards, determine how many points Eve will get if she plays optimally. Input There will be several test cases. The first line of input will contain a single positive integer N giving the number of test cases. After that line follow the test cases. Each test case starts with a line with a single positive integer k <= 26 which is the number of cards each player gets. The next line describes the k cards Adam has placed on the table, left to right. The next line describes the k cards Eve has (but she has not yet placed them on the table). A card is described by two characters, the first one being its value (2, 3, 4, 5, 6, 7, 8 ,9, T, J, Q, K, or A), and the second one being its suit (C, D, S, or H). Cards are separated by white spaces. So if Adam’s cards are the ten of clubs, the two of hearts, and the Jack of diamonds, that could be described by the line TC 2H JD Output For each test case output a single line with the number of points Eve gets if she picks the optimal way to arrange her cards on the table. Sample Input 3 1 JD JH 2 5D TC 4C 5H 3 2H 3H 4H 2D 3D 4D Sample Output 1 1 2
- 回答 2 已采纳 Java语言编写一个扑克牌发牌的程序，平均将54张牌打乱发给4个人，怎么实现 Java语言编写一个扑克牌发牌的程序，平均将54张牌打乱发给4个人，怎么实现
- 回答 3 已采纳 Erlang中的变量大部分情况下是"不可变"的(进程数据区域等特殊的除外), 据称是和并行相关, 不过这里我比较困惑, 既然Erlang进程设置了消息系统, 理论上讲消息都是一个一个处理的, 即:同一个进程中的消息处理不存在并行情况, 因此无需要"边量不变". 如果是在多进程情况下, 由于进程的数据之间是切分开的, 看起来也不太需要"变量不变"这个特性, why??? 可否举个例子说明在哪种情况下需要"变量不变"这个特性??? 备注: 本人初学Erlang, 理解错误的地方希望前辈们指点. Thanks. [b]问题补充：[/b] 根据night_stalker的回答, 看起来immutable是和"并行"没有太大关系的了... 还有别的方面的特性决定需要使用immutable的么??? [b]问题补充：[/b] 感谢night_stalker, 又去查了下资料, 应该是和进程调度有关, 详细见这里 : http://hi.baidu.com/timeless/blog/item/3f3dafc3cb84835db319a8ae.html 感觉上是由于immutable的特性决定进程可以比较轻松的进行调度而不消耗太多资源, 想比传统的进程/线程方式就有了很多好出. 另, to night_stalker, Erlang里应该不直接支持global-var的把...每个进程都有自己独立的数据区域, 相互之间应该是不share的... 再次感谢, 对这个问题有了更深入的认识:)~
- 回答 1 已采纳 在看《erlang程序设计》中讲到5.3.2中提到的比特语法表达式里有这样的写法，但是翻来翻去都没找到关于#语法的解释 请指教！多谢
- biubiuibiu的博客 在计算牌力或者牌型出现可能性方面，往往更多地是依靠已经拿到的牌来做概率计算。不讨论枪口位、大小盲注位置、下注分布的情况下，就各种手牌（2张）条件下，来做一个赢牌可能性的概率统计。 -------------------...
- 爱学习的小鹏友的博客 （一）C语言网https://www.dotcpp.com/ 水题+基础题偏多 标记 编编程的网站号 题目描述 难易程度 输入格式 输出格式 算法分类 √ 1 两数之和 简单 √ 2 两数相加...
- 汪雯琦的博客 1. 扑克牌54张，平均分成2份，求这2份都有2张A的概率。 M表示两个牌堆各有2个A的情况：M=4(25!25!) N表示两个牌堆完全随机的情况：N=27!27! 所以概率为：M/N = 926/53*17 2.男生点击率增加，女生点击率增加，总体...
- 4年前binhuazhuzhu的博客 3. ★用一种算法来颠倒一个链接表的顺序。现在在不用递归式的情况下做一遍。 ★用一种算法在一个循环的链接表里插入一个节点，但不得穿越链接表。 ★用一种算法整理一个数组。你为什么选择这种方法? ...
- 五十弦声的博客 大一寒假训练四（二进制枚举） A题链接 643 teacher Li Description : This time,suddenly,teacher Li wants to find out who have missed interesting DP lesson to...现在想从这些扑克牌中取出一些牌，让这些牌...
- 4年前JLongZhan的博客 3. ★用一种算法来颠倒一个链接表的顺序。现在在不用递归式的情况下做一遍。 ★用一种算法在一个循环的链接表里插入一个节点，但不得穿越链接表。 ★用一种算法整理一个数组。你为什么选择这种方法? ...
- 天上飞着得鱼的博客 8月31日，百度面试题：不使用随机数的洗牌算法，详情： http://topic.csdn.net/u/20120831/10/C837A419-DFD4-4326-897C-669909BD2086.html ； 9月6日，阿里笔试题：平面上有很多点，点与点之间有可能有连线，求这个...
- 南七程序员毛毛的博客 3. ★用一种算法来颠倒一个链接表的顺序。现在在不用递归式的情况下做一遍。 ★用一种算法在一个循环的链接表里插入一个节点，但不得穿越链接表。 ★用一种算法整理一个数组。你为什么选择这种方法? ★用一种...
- 7年前fireae的博客 3. ★用一种算法来颠倒一个链接表的顺序。现在在不用递归式的情况下做一遍。 ★用一种算法在一个循环的链接表里插入一个节点，但不得穿越链接表。 ★用一种算法整理一个数组。你为什么选择这种方法? ★用一种...
- 4年前weixin_34161029的博客 3. 用一种算法来颠倒一个链接表的顺序。现在在不用递归式的情况下做一遍。 用一种算法在一个循环的链接表里插入一个节点，但不得穿越链接表。 用一种算法整理一个数组。你为什么选择这种方法? 用一种算法使通用...