#P1555. Bash Plays with Functions
Bash Plays with Functions
描述
Bash got tired on his journey to become the greatest Pokémon master. So he decides to take a break and play with functions.
Bash defines a function , which denotes the number of ways of factoring into two factors and such that . In other words, is the number of ordered pairs of positive integers such that and .
But Bash felt that it was too easy to calculate this function. So he defined a series of functions, where is defined as:
$$f_{r+1}(n) = \sum_{u \cdot v = n} f_r(u) \cdot f_r(v)$$Where is any ordered pair of positive integers, they need not to be co-prime.
Now Bash wants to know the value of for different and . Since the value could be huge, he would like to know the value modulo . Help him!
题意
定义函数为满足且的有序对的个 数。
定义递推关系:
给定q次询问,每次询问的值。
数据范围:
输入
The first line contains an integer () — the number of values Bash wants to know.
Each of the next lines contain two integers and (, ), which denote Bash wants to know the value .
输出
Print integers. For each pair of and given, print modulo on a separate line.
样例
5
0 30
1 25
3 65
2 5
4 48
8
5
25
4
630