CF757E.Bash Plays with Functions
省选/NOI-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Bash got tired on his journey to become the greatest Pokemon master. So he decides to take a break and play with functions.
Bash defines a function _f_0(n), which denotes the number of ways of factoring n into two factors p and q such that gcd(p, q) = 1. In other words, _f_0(n) is the number of ordered pairs of positive integers (p, q) such that p·q = n and gcd(p, q) = 1.
But Bash felt that it was too easy to calculate this function. So he defined a series of functions, where f__r + 1 is defined as:

Where (u, v) is any ordered pair of positive integers, they need not to be co-prime.
Now Bash wants to know the value of f__r(n) for different r and n. Since the value could be huge, he would like to know the value modulo 109 + 7. Help him!
巴什在成为最强宝可梦大师的旅途中感到疲惫了,于是决定休息一下,玩一玩函数。
巴什定义了一个函数 $ f_0(n) $,表示将 $ n $ 分解为两个因子 $ p $ 和 $ q $ 的方案数,使得 $ \gcd(p, q) = 1 。换言之, f_0(n) $ 是满足 $ p \cdot q = n $ 且 $ \gcd(p, q) = 1 $ 的正整数有序对 $ (p, q) $ 的个数。
但巴什觉得计算这个函数太简单了,于是他定义了一组函数,其中 $ f_{r+1} $ 定义为:

其中 $ (u, v) $ 是任意正整数有序对,它们不必互质。
现在巴什想知道对于不同 $ r $ 和 $ n $ 的 $ f_r(n) $ 的值。由于结果可能非常大,他希望得到该值对 $ 10^9 + 7 $ 取模的结果。请帮助他!
输入格式
The first line contains an integer q (1 ≤ q ≤ 106) — the number of values Bash wants to know.
Each of the next q lines contain two integers r and n (0 ≤ r ≤ 106, 1 ≤ n ≤ 106), which denote Bash wants to know the value f__r(n).
第一行包含一个整数 $ q ( 1 \leq q \leq 10^6 $)——表示 Bash 想要知道的值的个数。
接下来的 $ q $ 行,每行包含两个整数 $ r $ 和 $ n ( 0 \leq r \leq 10^6 , 1 \leq n \leq 10^6 $),表示 Bash 想要求出 $ f_r(n) $ 的值。
输出格式
Print q integers. For each pair of r and n given, print f__r(n) modulo 109 + 7 on a separate line.
输出 q 个整数。对于每组给定的 r 和 n,在单独一行中输出 f__r(n) 对 109+7 取模的结果。
输入输出样例
输入#1
5 0 30 1 25 3 65 2 5 4 48
输出#1
8 5 25 4 630
输入解题思路,AI测评打分。不知道怎么写?