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 Fighting the Landlords is a card game which has been a heat for years in China. The game goes with the 54 poker cards for 3 players, where the “Landlord” has 20 cards and the other two (the “Farmers”) have 17. The Landlord wins if he/she has no cards left, and the farmer team wins if either of the Farmer have no cards left. The game uses the concept of hands, and some fundamental rules are used to compare the cards. For convenience, here we only consider the following categories of cards: 1.Solo: a single card. The priority is: Y (i.e. colored Joker) > X (i.e. Black & White Joker) > 2 > A (Ace) > K (King) > Q (Queen) > J (Jack) > T (10) > 9 > 8 > 7 > 6 > 5 > 4 > 3. It’s the basic rank of cards. 2.Pair : two matching cards of equal rank (e.g. 3-3, 4-4, 2-2 etc.). Note that the two Jokers cannot form a Pair (it’s another category of cards). The comparison is based on the rank of Solo, where 2-2 is the highest, A-A comes second, and 3-3 is the lowest. 3.Trio: three cards of the same rank (e.g. 3-3-3, J-J-J etc.). The priority is similar to the two categories above: 2-2-2 > A-A-A > K-K-K > . . . > 3-3-3. 4.Trio-Solo: three cards of the same rank with a Solo as the kicker. Note that the Solo and the Trio should be different rank of cards (e.g. 3-3-3-A, 4-4-4-X etc.). Here, the Kicker’s rank is irrelevant to the comparison, and the Trio’s rank determines the priority. For example, 4-4-4-3 > 3-3-3-2. 5.Trio-Pair : three cards of the same rank with a Pair as the kicker (e.g. 3-3- 3-2-2, J-J-J-Q-Q etc.). The comparison is as the same as Trio-Solo, where the Trio is the only factor to be considered. For example,4-4-4-5-5 > 3-3-3-2-2. Note again, that two jokers cannot form a Pair. 6.Four-Dual: four cards of the same rank with two cards as the kicker. Here, it’s allowed for the two kickers to share the same rank. The four same cards dominates the comparison: 5-5-5-5-3-4 > 4-4-4-4-2-2. In the categories above, a player can only beat the prior hand using of the same category but not the others. For example, only a prior Solo can beat a Solo while a Pair cannot. But there’re exceptions: 7.Nuke: X-Y (JOKER-joker). It can beat everything in the game. 8.Bomb: 4 cards of the same rank. It can beat any other category except Nuke or another Bomb with a higher rank. The rank of Bombs follows the rank of individual cards: 2-2-2-2 is the highest and 3-3-3-3 is the lowest. Given the cards of both yours and the next player’s, please judge whether you have a way to play a hand of cards that the next player cannot beat you in this round. If you no longer have cards after playing, we consider that he cannot beat you either. You may see the sample for more details. Input The input contains several test cases. The number of test cases T (T<=20) occurs in the first line of input. Each test case consists of two lines. Both of them contain a string indicating your cards and the next player’s, respectively. The length of each string doesn’t exceed 17, and each single card will occur at most 4 times totally on two players’ hands except that the two Jokers each occurs only once. Output For each test case, output Yes if you can reach your goal, otherwise output No. Sample Input 4 33A 2 33A 22 33 22 5559T 9993 Sample Output Yes No Yes Yes

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

void analyze_hand(void){//这里开始看不懂 int rank,suit,card,pass,run;straight=1;flush=1;four=0;three=0;pairs=0; /*sortcardsbyrank*/ for(pass=1;pass<NUM_CARDS;pass++)//1-4 for(card=0;card<NUM_CARDS-pass;card++){//0-3,0-2,0-1,0 rank=hand[card][RANK];suit=hand[card][SUIT]; if(hand[card+1][RANK]<rank){ hand[card][RANK]=hand[card+1][RANK];hand[card][SUIT]=hand[card+1][SUIT]; hand[card+1][RANK]=rank;hand[card+1][SUIT]=suit; } } /*checkforflush*/ suit=hand[0][SUIT]; for(card=1;card<NUM_CARDS;card++) if(hand[card][SUIT]!=suit)flush=0; /*checkforstraight*/ for(card=0;card<NUM_CARDS-1;card++) if(hand[card][RANK]+1!=hand[card+1][RANK]) straight=0; /*checkfor4-of-a-kind,3-of-a-kind,and pairs by looking for "runs" of card swith identical ranks*/ card=0; while(card<NUM_CARDS){ rank=hand[card][RANK];run=0; do{run++;card++; } while(card<NUM_CARDS&&hand[card][RANK]==rank); switch(run){case 2:pairs++;break;case 3:three=1;break;case 4:four=1;break;} }

c语言有关于纸牌游戏的字符串识别问题

Problem Description Shut the Box is a one-player game that begins with a set of N pieces labeled from 1 to N. All pieces are initially "unmarked" (in the picture at right, the unmarked pieces are those in an upward position). In the version we consider, a player is allowed up to T turns, with each turn defined by an independently chosen value V (typically determined by rolling one or more dice). During a turn, the player must designate a set of currently unmarked pieces whose numeric labels add precisely to V, and mark them. The game continues either until the player runs out of turns, or until a single turn when it becomes impossible to find a set of unmarked pieces summing to the designated value V (in which case it and all further turns are forfeited). The goal is to mark as many pieces as possible; marking all pieces is known as "shutting the box." Your goal is to determine the maximum number of pieces that can be marked by a fixed sequence of turns. As an example, consider a game with 6 pieces and the following sequence of turns: 10, 3, 4, 2. The best outcome for that sequence is to mark a total of four pieces. This can be achieved by using the value 10 to mark the pieces 1+4+5, and then using the value of 3 to mark piece 3. At that point, the game would end as there is no way to precisely use the turn with value 4 (the final turn of value 2 must be forfeited as well). An alternate strategy for achieving the same number of marked pieces would be to use the value 10 to mark four pieces 1+2+3+4, with the game ending on the turn with value 3. But there does not exist any way to mark five or more pieces with that sequence. Input Each game begins with a line containing two integers, N, T where 1 ≤ N ≤ 22 represents the number of pieces, and 1 ≤ T ≤ N represents the maximum number of turns that will be allowed. The following line contains T integers designating the sequence of turn values for the game; each such value V will satisify 1 ≤ V ≤ 22. You must read that entire sequence from the input, even though a particular game might end on an unsuccessful turn prior to the end of the sequence. The data set ends with a line containing 0 0. Output You should output a single line for each game, as shown below, reporting the ordinal for the game and the maximum number of pieces that can be marked during that game. Sample Input 6 4 10 3 4 2 6 5 10 2 4 5 3 10 10 1 1 3 4 5 6 7 8 9 10 22 22 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 Sample Output Game 1: 4 Game 2: 6 Game 3: 1 Game 4: 22

c++ 显示扑克牌牌面的系统函数

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.

``` #include<iostream> using namespace std; int count=0; int book[5]; char card[5][2]={'2','C','A','D','A','C','J','C','J','H'}; char a[5][2]; void dfs(int step){ if(step==5){ count++; return ; } for(int i=0;i<5;i++){ if(/*a[step][0]!=a[step-1][0]&&*/book[i]==0){//判断条件该牌未被标记且与上一张的牌号不相同，但我不知道应该如何写出这条判断语句，如果我将其注释掉，则输出120，是一个全排列。如果不注释，则输出为0. a[step][0]=card[i][0]; book[i]=1;//将用过的牌标记 dfs(step+1); book[i]=0;//取消标记 } } return ; } int main(){ dfs(0); cout<<count<<endl; return 0; } ``` ![图片说明](https://img-ask.csdn.net/upload/201504/27/1430134971_334457.png) ![图片说明](https://img-ask.csdn.net/upload/201504/27/1430134985_479660.png) 我未按照题目要求，只是给出了特定的扑克牌进行算法可行性的验证，如第三组数据所示，该程序应输出48. 现在的问题是不知如何进行条件的判断。悉心向各位请教

# 需求： 1、一副没有J、Q、K、A、大小王的扑克牌（40张牌），编号为1-40张牌。第一回合，从40张牌中给双方各随机抽取5张牌，抽出的牌在原数组里删除。第二回合，从剩下30张牌中给双方各随机抽取5张牌，抽出的牌在原数组里删除。第三回合，从剩下20张牌中给双方各随机抽取5张牌，抽出的牌在原数组里删除。第四回合，从剩下10张牌中给双方各随机抽取5张牌，抽出的牌在原数组里删除。四回合游戏结束后输出“请重新进行游戏”并结束程序。每回合结束记录用户获胜情况、计算机获胜情况和总的回合数。 2、存储结构可用顺序二叉树也可用二叉链表。 3、带有软件系统界面主函数main，功能完整（如：用户选择1开始游戏并随机抽取扑克牌；用户选择0退出执行程序；用户选择1后有两个选择，1为开始出本回合牌，2为不出牌；用户输入其他信息则输出错误信息并要求用户重新选择操作）。 4、主要代码及每个循环后请附上注释。 ## 游戏规则： 1、两个人进行纸牌游戏，其中一个人为用户，另一个人为计算机。 2、每轮每人各发5张牌，各自以这5张牌建立二叉排序树。 3、A最小，2次小，9次大，10最大。 4、不用区分相同数字的花色，有可能一方抽到A，另一方也抽到A，这时候后出方手里的A就再也出不了；有可能一方抽到10，另一方也抽到10，这时候先出方获胜。 5、由用户先出，轮流出牌，每次只能出一张并且要比别人出的大（可出现第一手出10压制对手再出A）。 6、手中的牌没有别人的大则选择不出，最先出完的人获胜。 在这里先谢过啦！

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

“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内，我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年，古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合，再掺入煅烧石灰石制成的石灰，由此得来了人...

loonggg读完需要3分钟速读仅需 1 分钟大家好，我是你们的校长。我之前讲过，这年头，只要肯动脑，肯行动，程序员凭借自己的技术，赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

MySQL数据库面试题（2020最新版）

HashMap底层实现原理，红黑树，B+树，B树的结构原理 Spring的AOP和IOC是什么？它们常见的使用场景有哪些？Spring事务，事务的属性，传播行为，数据库隔离级别 Spring和SpringMVC，MyBatis以及SpringBoot的注解分别有哪些？SpringMVC的工作原理，SpringBoot框架的优点，MyBatis框架的优点 SpringCould组件有哪些，他们...

《经典算法案例》01-08：如何使用质数设计扫雷（Minesweeper）游戏

《Oracle Java SE编程自学与面试指南》最佳学习路线图（2020最新版）