모든 챌린지
보통 0명 해결 정답률 0%

Count Dice Sequences

Count ordered die-roll sequences with a given total.

A standard die produces an integer from 1 through 6. Count all nonempty ordered sequences of outcomes whose sum is target. Different orders count separately. Return the count modulo 1,000,000,007.

Implement dice_combinations(target).

Input

target: The required sum of all rolls.

Output

Return the number of sequences modulo 1,000,000,007.

제약 조건

1 ≤ target ≤ 1,000,000. Taking a count modulo 1,000,000,007 means returning its remainder after division by that number.

예시

예시 1
입력:
target = 2

예상 출력:
expected = 2
입력:
long long target = 2;

예상 출력:
long long expected = 2;
입력:
long target = 2;

예상 출력:
long expected = 2;

설명

The two sequences are [2] and [1, 1].

예시 2
입력:
target = 4

예상 출력:
expected = 8
입력:
long long target = 4;

예상 출력:
long long expected = 8;
입력:
long target = 4;

예상 출력:
long expected = 8;

설명

The sequences are [4], [1,3], [3,1], [2,2], [1,1,2], [1,2,1], [2,1,1], and [1,1,1,1].

참고 자료

이 문제는 CodeUtility에 맞게 수정되었습니다. 위의 설명과 제한 조건을 따르세요.

다른 사람의 풀이 보기

커뮤니티 솔루션

아직 공개된 풀이가 없습니다. 문제를 풀고 첫 풀이를 공유하세요.