NOI Contest Archive

Archive / 2022 / Final Round — Day 1

Prime Game

Medium · National Olympiad in Informatics Sri Lanka 2022 - Day 1

Ranith and Manil are two brothers. Manil is in eighth grade and he is good at maths. Ranith is in eleventh grade and he is a smart programmer who has past experience in the National Olympiad in Informatics. Last week the Ministry of Education declared a holiday week for their school and they started to play during the vacation.

But these smart brothers decided to spend the vacation in a meaningful way. Instead of wasting all their free time on social media or computer games, they thought of inventing a new game that gives them brain exercise.

Manil, the younger brother came up with an idea. Manil gives a list of \(N\) natural numbers(\(a_1\),\(a_2\),\(a_3\),…,\(a_n\)) and he asks his brother to count the number of different rare subsequences of the original set. According to Manil a rare subsequences satisfies the below conditions,

Hint:-

Ranith, the programming kid says this game is too simple! He argues that this game can be automated using a computer program and can be solved for very large number sets. In this problem, you have to work as Ranith to solve the problem.

Input Format

Output Format

Constraints

Limits

Sample Input 0

5
4 2
1 2 7 4
7 3
3 11 5 1 7 3 1
8 1
1 2 6 1 1 5 19 1
10 5
1 2 4 8 5 3 1 12 2 2
4 1
1 1 2 2

Sample Output 0

1
2
4
2
2

Sample Input 1

1
4 1
1 3 1 3

Sample Output 1

4