#SP0000231. Đếm cách phân tích thừa số nguyên tố (Counting Factorizations)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Đếm cách phân tích thừa số nguyên tố (Counting Factorizations)
Counting Factorizations
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Every positive integer has a unique prime factorization where are distinct primes and . Define as the multiset containing all values . Order does not matter, but multiplicities do. The multiset is empty.
Given positive integers , count the number of distinct positive integers for which equals the given multiset. Print the answer modulo . A value may appear separately as a prime base and as an exponent.
Input
The first line contains . The second line contains exactly integers .
Output
Print the number of distinct positive integers whose multiset matches the input, modulo .
Subtasks
-
Subtask 1 (20 points): ; for every .
-
Subtask 2 (30 points): ; for every .
-
Subtask 3 (50 points): ; for every .
Examples
Input
2
1 3 2 3
Output
2
Explanation
The input multiset is and . There must be two distinct prime bases, necessarily and , leaving exponents and . Assigning them yields or . Both produce the required multiset, and no other choices exist. The answer is .