搜索
您的当前位置:首页正文

ACM校级竞赛题目

来源:二三娱乐
Marble Madness

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)

Problem Description

Wilson 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

The competition between dog and men

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)

Problem Description

Nowadays, LiuJun of DLU thinks of a simple math problem. The problem is derive from primary school: Two men get close with the same speed v1, there is a dog run between them with speed v2. It is easy to answer the question that how long dog has run (D) before they meet. Since it is so easy, he want to change this problem. Two men can see each other within 10 meters, if their distance less than 10 meters, then they stop. The dog can run at most L2 meters. At first, two man's distance is L1 meters, their speeds are changed. The left man's speed becomes

v1/tansintand the right man's speed becomesv1/tancost. The dog's speed also

22changed to v2tan1.55741sinttancost21.557412。



Input

the first line N, then N lines follows

each line has 4 parameters L1, L2, V1, V2;

0<=L1,L2<=100,0Output

D represent how long dog has run, round to integer.

Sample Input

2

9 1 2 3 47 11 25 9

Sample Output

0 11

Wilson’s Tables

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Problem Description

Today is Wilson of DLU birthday. He invites a lot of friends. Now it's dinner time. Wilson wants

to know how many tables he needs at least. You have to notice that not all the friends know each other, and all the friends do not want to stay with strangers.

One important rule for this problem is that if I tell you A knows B, and B knows C, that means A, B, C know each other, so they can stay in one table.

For example: If I tell you A knows B, B knows C, and D knows E, so A, B, C can stay in one table, and D, E have to stay in the other one. So Ignatius needs 2 tables at least.

Input

The input starts with an integer T(1<=T<=25) which indicate the number of test cases. Then T test cases follow. Each test case starts with two integers N and M(1<=N,M<=1000). N indicates the number of friends, the friends are marked from 1 to N. Then M lines follow. Each line consists of two integers A and B(A!=B), that means friend A and friend B know each other. There will be a blank line between two cases.

Output

For each test case, just output how many tables Wilson needs at least. Do NOT print any blanks.

Sample Input 2 5 3 1 2 2 3 4 5 5 1 2 5

Sample Output 2 4

因篇幅问题不能全部显示,请点此查看更多更全内容

Top