编程介的小学生 2019-03-05 23:00 采纳率: 20.5%
浏览 213

一个数组的切分的算法问题,得到单空间的概率点,采用C语言方式的回答

Problem Description
oyvind likes to test his future employees, especially with funny games.

This time he has invented a game where you start out with B black marbles and W white ones in a bag.

You also have endless supplies of both kinds of marbles outside the bag. The game proceeds in rounds. In each round, you take two marbles at random out of the bag, and put one marble back in (possibly another color than any of the two you took out), obeying the following rules:

  1. When you take out two white marbles, you put a black one back in.

  2. When you take out one black and one white, you put a white marble back in.

  3. When you take out two black marbles, you put a black one back in.

At the end of this game, there will only be one marble in the bag. This marble may be white with a probability and black with a probability given the number of marbles of each colour you start with. Your job is to find these probabilities.

Input
The input will start with a line giving the number of test cases, T. Each test case will be presented at one line with two integers, B and W, separated by a single space, representing the number of black and white marbles respectively.

Output
There should be one line of output for each test case with two floating point numbers separated by a single space. The first number should represent the probability that the last marble is black, and the second the probability that the last marble is white.

Notes and Constraints
0 < T <= 100
0 <= B,W <= 50000
0 < B +W
Any answer within 10^-6 of the correct one will be accepted.

Sample Input
2
1 1
3 0

Sample Output
0.00 1.00
1.00 0.00

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 逻辑谓词和消解原理的运用
    • ¥15 请求分析基于spring boot+vue的前后端分离的项目
    • ¥15 三菱伺服电机按启动按钮有使能但不动作
    • ¥15 js,页面2返回页面1时定位进入的设备
    • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
    • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?