时间限制: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 ;
}

hihocoder 1177 : 顺子的更多相关文章

  1. 模拟 hihoCoder 1177 顺子

    题目传送门 /* 模拟:简单的照着规则做就可以了,把各种情况考虑到,虽然比赛写的丑了点,但能1Y还是很开心的:) */ #include <cstdio> #include <cst ...

  2. hihocoder #1177 : 顺子 模拟

    #1177 : 顺子 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/problemset/problem/1177 ...

  3. ACM学习历程—Hihocoder 1177 顺子(模拟 && 排序 && gcd)(hihoCoder挑战赛12)

      时间限制:6000ms 单点时限:1000ms 内存限制:256MB   描述 你在赌场里玩梭哈,已经被发了4张牌,现在你想要知道发下一张牌后你得到顺子的概率是多少? 假定赌场使用的是一副牌,四种 ...

  4. 【hihoCoder】【挑战赛#12】

    模拟+枚举+模拟……+构造 QAQAQQQ rank12求杯子! A 顺子 ……模拟题,分类讨论一下就好了……比如当前四张牌是不是同一花色……是不是连续的四张牌,如果是连续的四张牌,是不是两边的……( ...

  5. hihocoder -1121-二分图的判定

    hihocoder -1121-二分图的判定 1121 : 二分图一•二分图判定 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 大家好,我是小Hi和小Ho的小伙伴Net ...

  6. Hihocoder 太阁最新面经算法竞赛18

    Hihocoder 太阁最新面经算法竞赛18 source: https://hihocoder.com/contest/hihointerview27/problems 题目1 : Big Plus ...

  7. hihoCoder太阁最新面经算法竞赛15

    hihoCoder太阁最新面经算法竞赛15 Link: http://hihocoder.com/contest/hihointerview24 题目1 : Boarding Passes 时间限制: ...

  8. 【hihoCoder 1454】【hiho挑战赛25】【坑】Rikka with Tree II

    http://hihocoder.com/problemset/problem/1454 调了好长时间,谜之WA... 等我以后学好dp再来看为什么吧,先弃坑(╯‵□′)╯︵┻━┻ #include& ...

  9. 【hihocoder#1413】Rikka with String 后缀自动机 + 差分

    搞了一上午+接近一下午这个题,然后被屠了个稀烂,默默仰慕一晚上学会SAM的以及半天4道SAM的hxy大爷. 题目链接:http://hihocoder.com/problemset/problem/1 ...

随机推荐

  1. POJ.1003 Hangover ( 水 )

    POJ.1003 Hangover ( 水 ) 代码总览 #include <cstdio> #include <cstring> #include <algorithm ...

  2. UVA.122 Trees on the level(二叉树 BFS)

    UVA.122 Trees on the level(二叉树 BFS) 题意分析 给出节点的关系,按照层序遍历一次输出节点的值,若树不完整,则输出not complete 代码总览 #include ...

  3. AIM Tech Round (Div. 2) B

    B. Making a String time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  4. bzoj 4723 [POI2017]Flappy Bird 模拟

    [POI2017]Flappy Bird Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 482  Solved: 196[Submit][Status ...

  5. HDU 4576 DP

    Robot Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others)Total Sub ...

  6. HDU1531 差分约束

    King Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  7. 名人问题/名流问题/Celebrity

    问题描述:名人问题一个名人就是指这样一个人:所有其他人都认识他,并且他不认识任何其他人.现在有一个N个人的集合,以及他们之间的认识关系.求一个算法找出其中的名人(如果有的话)或者判断出没有名人(如果没 ...

  8. 例子Architecting Android…The clean way?----代码分析

    Presention层:   整个应用启动的时候,就执行依赖的初始化.编译项目之后,Dagger依赖框架使用ApplicationComponent生成一个DaggerApplicationCOmpo ...

  9. 【Foreign】不等式 [数论]

    不等式 Time Limit: 10 Sec  Memory Limit: 128 MB Description 小z热衷于数学. 今天数学课的内容是解不等式:L<=S*x<=R .小z心 ...

  10. 【51NOD-0】1081 子段求和

    [算法]树状数组(区间和) [题解]记得开long long #include<cstdio> #include<cstring> #include<algorithm& ...