Logo
(追記) (追記ここまで)

35017번 - Wanted: Second Sock 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB543100.000%

문제

Nikita is preparing for a competition. The most challenging part of this task is to find a pair of matching socks. In the drawer, there are $p$ different pairs of socks, as well as $m$ single socks whose pairs he has lost long ago. Nikita takes socks one by one until he finds two matching socks among those he has pulled out. What is the expected number of socks Nikita will pull out?

Calculate this expected value modulo the prime number 10ドル^9 + 7$. Specifically, if the answer is a rational number $x / y,ドル you need to output a number $a$ such that 0ドル \le a < 10^9 + 7$ and $a \cdot y = x \pmod{10^9 + 7}$.

입력

The first line contains an integer $t$: the number of test cases (1ドル \le t \le 10^4$). The following lines describe the test cases.

Each test case is given on a separate line containing two integers $p$ and $m$: the number of pairs of socks and the number of single socks in the drawer (1ドル \le p \le 10^6$; 0ドル \le m \le 10^6$).

출력

For each test case, output a line containing a single integer: the answer to the problem.

제한

예제 입력 1

1
1 1

예제 출력 1

666666674

노트

In the first test case, the expected value is 8ドル / 3,ドル which equals 666ドル,666円,674円$ modulo 10ドル^9 + 7$.

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > ICPC 2025-2026 Northwestern Russia Qualification N번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /