sicily 1242. Suit Distribution
来源:互联网 发布:娶俄罗斯女人知乎 编辑:程序博客网 时间:2024/06/06 08:32
1242. Suit Distribution
Constraints
Time Limit: 1 secs, Memory Limit: 32 MB
Description
Bridge is a 4-player (two teams of two) card game with many complicated conventions that even experienced players have difficulty keeping track of. Fortunately, we are not interested in these conventions for this problem. In fact, it is not even important if you understand how to play the game.
What is important to know is that the way the cards are distributed among your two opponents often determine whether you will be successful in your game. For example, suppose you and your partner hold 8 spades. The remaining 5 spades are held by your opponents (since there are 13 cards in each suit) and can be distributed in the following ways: 0-5, 1-4, 2-3. Notice that a 0-5 "split" can be realized in two ways---opponent 1 has no spade and opponent 2 has 5 spades, or vice versa.
Good bridge players know that the best line of play often depends on the distribution. Sometimes good players can "read their opponents' cards" and determine the distribution, but sometimes even good players have to guess. In those cases, knowing the probability of the different distributions would be useful in making an educated guess.
You can assume that the 52 cards in a deck are dealt out randomly to 4 players, so that every player has 13 cards, and that you know which 26 cards your team holds.
Input
The input consists of a number of cases. Each case consists of two integers a, b (0 <= a, b <= 13, a + b <= 13). The input is terminated by a = b = -1.
Output
For each case, print the probability of a split of a+b cards so that one opponent has a cards and the other has b cards in the format as shown in the sample output. You may assume that the remaining cards in the suit are held by you and your partner. Output the probabilities to 8 decimal places.
Sample Input
2 23 34 2-1 -1
Sample Output
2-2 split: 0.406956523-3 split: 0.355279504-2 split: 0.48447205
题目大意是给定26张牌,平均分成2份后
使其中黑桃的分布为a:b的概率
简单的数学问题
[2*]c(a+b, a) * c(26-a-b, 13-a) / c(26, 13)
注意当a!=b时,c(a+b, a)要乘2
#include <stdio.h>int c(int k, int total) { double ans = 1.0; for (int i = total-k+1; i <= total; ++i) ans *= i; for (int i = 1; i <= k; ++i) ans /= i; return ans;}int main(){ int a, b; while (scanf("%d%d", &a, &b)) { if (a == -1 && b == -1) break; int spades = a + b; double key1 = c(a, spades); if (a != b) key1 *= 2.0; double key2 = c(13-a, 26-spades); double all = c(13, 26); //printf("%.f %.f %.f\n", key1, key2, all); printf("%d-%d split: %.8f\n", a, b, key1*key2/all); }}
- sicily 1242. Suit Distribution
- Suit
- Distribution
- Strong suit
- Django-suit
- suit案例
- cufflinks suit
- Junit 4 test suit
- oracle no suit driver
- ASS - Apache Server Suit
- DockPanel Suit - 1
- vim latex-suit
- Junit4 Suit Test
- DockPanel Suit - 1
- dhtmlx suit下载
- spirng + junit + suit 测试
- 安装 spring tool suit
- Burp Suit使用手册
- [bat][批处理][自动化测试]用批处理实现以日期和时间做文件文件夹名
- Spark修炼之道(进阶篇)——Spark入门到精通:第二节 Hadoop、Spark生成圈简介
- 徒步一千里 1930年 (長白縣)
- Volley源码分析
- python modules: os, sys, platform
- sicily 1242. Suit Distribution
- android TypedValue.applyDimension()的作用
- 在opencv中,如何将二维数组转化为一副图像进行显示?
- Linux SPI总线和设备驱动架构之二:SPI通用接口层
- 根据卫星仰角和方位角使用html5绘制天空图(投影图)
- OpenGL顶点缓冲区对象(VBO)
- 用AFNetworking 检测 手机的网络状态
- linux定时备份mysql数据库
- 调试静态库的时候的莫名崩溃