Counting Functions
Time limit1sMemory limit32 MB
Count functions f on {1..N} such that each i returns to itself after exactly A_i iterations, for N up to 16.
- Level
Hard8 of 10
- Topics
- Combinatorics, Graph, Bit manipulation
- Solved
- No attempts yet
Problem
Minhyuk built a function from the set to itself. Write for applying exactly times in a row. The function Minhyuk built satisfies the following.
Minhyuk wants to know how many different functions satisfy this. Given , write a program that counts them. Two functions and are different when there is at least one with .
Input
The first line contains the size of the domain, . ()
The second line contains the positive integers , separated by spaces. ()
Output
Print the number of functions that satisfy the condition on the first line.