#FT0000086. Đếm dãy con tăng độ dài K (Increasing Subsequences)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Đếm dãy con tăng độ dài K (Increasing Subsequences)
Increasing Subsequences
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given an integer sequence and an integer , a subsequence of length exactly is specified by indices
It is valid if . Subsequences with identical value sequences but different chosen positions count separately.
Count the strictly increasing subsequences of length , and print the result modulo .
Input
The first line contains integers .
Exactly more lines follow; line contains one integer .
Output
Print one integer between and : the count modulo .
Subtasks
- Subtask 1 (20 points): ; ; for every .
- Subtask 2 (30 points): ; ; for every .
- Subtask 3 (50 points): ; ; for every .
Examples
Input
4 3
1
2
2
10
Output
2
Explanation
We must choose three positions with strictly increasing values. Exactly two choices work: indices and . Both yield the values , but count separately because the value comes from different positions.
The two occurrences of value cannot be selected together. The count is .