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

21034번 - Go To Goal 다국어

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

문제

Ani is playing a game containing a piece and 2N + M + 1 squares, numbered from 0 to 2N + M. The piece is initially located at square 0. Ani also has N super cards and M normal cards.

In one turn, Ani can use one of her unused card. If Ani chooses to use a normal card, her piece will move one square ahead (i.e. from square x to square x + 1). Otherwise, if Ani chooses to use a super card, her piece will move two squares ahead (i.e. from square x to square x + 2). Ani cannot use a super card too often–she cannot use three super cards in three consecutive turns.

After N + M turns, the piece should be located at square 2N + M, which is the goal. Ani is wondering the number of possible paths that her piece can use to the goal. Two paths are considered different if the piece is located at different squares after the same number of turns.

For example, if N = 3, and M = 1, then there are two different paths that Ani’s piece can use to the goal:

  1. Use the normal card in the second turn, and use the super cards in the first, third, and fourth turn.
  2. Use the normal card in the third turn, and use the super cards in the first, second, and fourth turn.

Note that Ani cannot use the normal card in the first turn, since then she will need to use the super cards in the last three turns consecutively.

입력

Input begins with a line containing two integers: N M (1 ≤ N, M ≤ 100 000) representing the number of super cards and normal cards, respectively.

출력

Output in a line an integer representing the number of possible paths that her piece can use to the goal. As this output can be large, you need to modulo the output by 1 000 000 007.

제한

예제 입력 1

3 1

예제 출력 1

2

This is the example from the problem description.

예제 입력 2

5 1

예제 출력 2

0

There is no path for Ani’s piece that satisfies all the conditions in the problem description.

예제 입력 3

5 2

예제 출력 3

3

힌트

출처

ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2019 M번

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

출처

대학교 대회

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

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