ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила

SPbSU ITMO contest. Petrozavodsk training camp. Winter 2008

Описание     Задачи     Отправить на проверку     Состояние проверки     Результаты
Соревнование завершено

B. Big Brother

Ограничение времени: 1.0 секунды
Ограничение памяти: 64 МБ
Alex and Bob are brothers. Alex is the elder brother, and Bob is the younger one. Since the last New Year Day, their parents started giving them pocket money as a fee for household assistance or good marks in school. The children are in the seventh heaven. They became A-students, run to the shop one ahead of another to buy some bread and clean the room in the sake of making more money. Brothers do not spend their money but store them in two separate piggy-banks: Alex wants to buy a bicycle, and Bob aims to save a million.
Alex is the elder brother, so he would become angry if at some moment the sum in the piggy-bank of the younger brother becomes greater than in his one. Certainly, he would break all the windows in the nearest house in such case. Bob is above all this — he has a great aim, so such an issue is not worth breaking nerves.
Poor brothers! They don't know that in fact not all their good deeds will be paid, and the sums to be given away for them are determined well ahead. Notably, during this year Alex will be given K euros, and Bob will be given M euros. A good deed is rewarded by giving 1 euro, and in no case the brothers would be paid simultaneously.
Consider K good deeds of Alex and M those of Bob which will be paid off and assume that every permutation of those deeds is equally probable. Find the probability for the window in the next house to remain unbroken during the year.

Исходные данные

In the first line there is the number of test cases N. N ≤ 2004. Each of the next N lines consists of two integers Ki and Mi — the amounts of money to be paid to elder and younger brother, respectively. 0 ≤ Ki, Mi ≤ 104.

Результат

For each test case, output the answer on a separate line with precision not less than 10−6.

Пример

исходные данныерезультат
3
1 0
0 1
1 1
1
0
0.5
Источник задачи: SPbSU ITMO contest. Petrozavodsk training camp. Winter 2008.
Чтобы отправить решение этой задачи на проверку перейдите в Архив задач: 1619. Big Brother