PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#QHD0000018. Đếm tháp (Counting Towers)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm tháp (Counting Towers)
Counting Towers
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
Consider a rectangular board of size . Divide the whole board into rectangles whose side lengths are positive integers.
The rectangles must not overlap or extend beyond the board, and their union must cover every cell. Two partitions are distinct if their rectangle boundaries differ.
Count all valid partitions modulo .
Input
One line contains the integer , the length of a board of width .
Output
Print the number of valid partitions modulo .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
2
Output
8
Explanation
For , the board is by . Counting all distinct partitions into rectangles with positive integer side lengths yields , so the program prints 8.