时间限制:6000ms
单点时限:1000ms
内存限制:256MB

描述

你在赌场里玩梭哈,已经被发了4张牌,现在你想要知道发下一张牌后你得到顺子的概率是多少?

假定赌场使用的是一副牌,四种花色的A、2、3、...、J、Q、K共52张,这副牌只发给你了4张,你的剩下一张牌从剩下48张中任意取出一张。

顺 子指的是点数连续的五张牌,包括10、J、Q、K、A这种牌型(不包含同花顺,即构成顺子的五张牌花色不能相同)。参 见:https://zh.wikipedia.org/wiki/%E6%92%B2%E5%85%8B%E7%89%8C%E5%9E %8B#.E7.89.8C.E5.9E.8B

输入

一行四个被空格隔开的长度为2或3的字符串,XY,表示你手里的牌。

X为2~10、J、Q、K、A中一个,表示点数,Y为S、H、C、D分别表示黑桃、红心、梅花和方块。

输出

一行一个分数表示概率,注意你的分数需为最简分数,若答案为0输出0/1。

样例输入
10S JS QS KD
样例输出
1/6
/**
题意:如题给出了4张扑克 然后求得到顺子的概率
做法:模拟 首先1,2,3,4,5不算顺子,然后题中的要求是不能是同花
然后开始模拟
**/
#include <iostream>
#include <string.h>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
char ch[][];
int mmap[];
int main()
{
//#ifndef ONLINE_JUDGE
// freopen("in.txt","r",stdin);
//#endif // ONLINE_JUDGE
while(~scanf("%s %s %s %s",ch[],ch[],ch[],ch[]))
{
int res = ,cet = ;
bool prime = true;
for(int i=; i<; i++)
{
int len = strlen(ch[i]);
int tt = ;
for(int j=; j<len; j++)
{
if(isdigit(ch[i][j]))
{
tt = tt * + (ch[i][j] -'');
}
}
if(ch[i][] == 'A') tt = ;
if(ch[i][] == 'J') tt = ;
if(ch[i][] == 'Q') tt = ;
if(ch[i][] == 'K') tt = ;
mmap[i] = tt;
if(ch[i][len-] == 'S') res = ;
if(ch[i][len-] == 'H') res = ;
if(ch[i][len-] == 'C') res = ;
if(ch[i][len-] == 'D') res = ;
if(i == )
{
cet = res;
}
if(res != cet)
{
prime = false;
}
}
sort(mmap,mmap+);
int flag = ;
bool ok = true;
for(int i=; i<; i++)
{
if(mmap[i] - mmap[i-] == ) continue;
else if(mmap[i]- mmap[i-] == )
{
if(!flag) flag = i;
else ok = false;
}
else ok = false;
}
if(ok == false)
{
printf("0/1");
}
else
{
if(flag) ///在中间
{
if(prime) printf("1/16");
else printf("1/12");
}
else
{
if(!prime)
{
if(mmap[] == || mmap[] == ) printf("1/12");
else printf("1/6");
}
else
{
if(mmap[] == || mmap[] == ) printf("1/16");
else printf("1/8");
}
}
}
printf("\n");
}
return ;
}

最新文章

  1. centos 6.7 搭建tornado + nginx + supervisor的方法(已经实践)
  2. Yaf框架下类的自动加载
  3. Waiting Processed Cancelable ShowDialog
  4. Spark Streaming源码解读之生成全生命周期彻底研究与思考
  5. LeetCode(7) - Reverse Integer
  6. 使用FMDB,libqrencode实现二维码的生成并且保存到数据库
  7. openwrt 包makefile
  8. 从PRISM开始学WPF(三)Prism-Region?
  9. Jenkins结合.net平台综合应用之使用FileZilla搭建ftp服务器
  10. vue2.0配置路由
  11. shell编程中的循环语句
  12. [福大软工] Z班——Beta现场答辩反馈
  13. NSString copy &amp;&amp; strong
  14. MySQL开发面试题
  15. MYSQL中GROUP BY不包含所有的非聚合字段时的注意事项
  16. 前端(以Vue为例)webpack打包后dist文件包如何部署到django后台中
  17. python sqlite3 入门 (视频讲座)
  18. Linux Netfilter注册钩子点
  19. Virtual Box虚拟机下CentOS网络设置
  20. GET和POST请求区别

热门文章

  1. BZOJ3143:[HNOI2013]游走——题解
  2. POJ 3621 Sightseeing Cows | 01分数规划
  3. YBT 1.2 二分与三分
  4. ACE线程管理机制-面向对象的线程类ACE_Task
  5. git版本回退与撤销操作
  6. 阿里C++研发实习二面和三面面经
  7. asyncio Lock,Queue
  8. zk-web
  9. EntitySpace 常用语句
  10. 省队集训 Day1 残缺的字符串