1. 程式人生 > >HDU 6038 (2017 多校訓練賽1 1006) Function(圖論)

HDU 6038 (2017 多校訓練賽1 1006) Function(圖論)

You are given a permutation a from 0 to n1 and a permutation b from 0 to m1.

Define that the domain of function f is the set of integers from 0 to n1, and the range of it is the set of integers from 0 to m1.

Please calculate the quantity of different functions f satisfying that f(i)=bf(ai) for each i from 0 to n1.

Two functions are different if and only if there exists at least one integer from 0
 to n1 mapped into different integers in these two functions.

The answer may be too large, so please output it in modulo 109+7.