Все задачи
Средне Решено: 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. Следуйте условию и ограничениям выше.

Учитесь у других

Решения сообщества

Пока нет опубликованных решений. Решите задание, чтобы поделиться первым.