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

18752번 - Kilk 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB80232143.750%

문제

Find the number of strings consisting of x letters ‘a’ and y letters ‘b’ that have the length of their longest substring consisting of equal letters as small as possible under these conditions, and display it modulo 998 244 353.

입력

The first line contains a single integer t (1 ≤ t ≤ 105), denoting the number of test cases.

Each of the next t lines describes one test case and contains two integers x and y (1 ≤ x, y ≤ 2000).

출력

For each test case, display the required number.

제한

예제 입력 1

5
2 4
7 8
7 7
9 3
239 58

예제 출력 1

6
1
2
20
868098448

힌트

In the first test case, the strings are abbabb, bababb, babbab, bbaabb, bbabab, bbabba. In each of these strings, the length of the longest substring consisting of equal letters is 2, and there are no strings consisting of 2 letters ‘a’ and 4 letters ‘b’ with a smaller value.

출처

Camp > Petrozavodsk Programming Camp > Winter 2020 > Day 7: Gennady Korotkevich Contest 5 K번

Contest > Open Cup > 2019/2020 Season > Stage 11: Grand Prix of Gomel K번

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

출처

대학교 대회

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

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