PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#QHD0000004. Tổ hợp gieo xúc xắc (Dice Combinations)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tổ hợp gieo xúc xắc (Dice Combinations)
Dice Combinations
Source: CSES
Problem Statement
A standard die has six faces numbered from through . Each throw produces the number shown on the upper face.
Count the number of ordered sequences of at least one throw whose sum is exactly . Sequences with the same values in different orders are counted separately.
Print the answer modulo .
Input
The input consists of one integer , the target sum.
Output
Print one integer: the number of valid sequences modulo .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
3
Output
4
Explanation
Exactly four roll sequences total : , , , and . The sequences and are distinct because order matters.