题意:
给定两个整数 (n, m),求:
[prod_{i = 1} ^ n prod_{j = 1} ^ m operatorname{Fib}_{gcdleft(n, m
ight)}
]
其中 (operatorname{Fib}_n) 表示斐波那契数列的第 (n) 项,斐波那契数列按照如下方式递归定义:
[egin{equation}
operatorname{Fib}_n =
egin{cases}
1 & n = 1 ext{or} n = 2\
operatorname{Fib}_{n - 2} + operatorname{Fib}_{n - 1} & ext{otherwise}\
end{cases}
end{equation}
]
正文
开始推导!
老套路,先枚举 (gcdleft(i, j ight)), 设 (d = gcdleft( i, j ight))。
则考虑对于每个可行的 (d),对应的 (operatorname{Fib}_d) 被乘了多少次。
显然是:
[sum_{i = 1} ^ n sum_{j = 1} ^ m [gcdleft(i, j
ight) = d]\
= sum_{i = 1} ^ {lfloorfrac{n}{d}
floor} sum_{j = 1} ^ {lfloorfrac{m}{d}
floor} [gcdleft(i, j
ight) = 1]\
= sum_{i = 1} ^ {lfloorfrac{n}{d}
floor} sum_{j = 1} ^ {lfloorfrac{m}{d}
floor} sum_{t|gcdleft(i, j
ight)} mu left(t
ight)\
= sum_{t = 1} ^ {lfloorfrac{min{n, m}}{d}
floor} mu left(t
ight) cdot lfloorfrac{n}{dt}
floor cdot lfloorfrac{m}{dt}
floor
]
次。
即:
[ ext{原式} = prod_{d = 1} ^ {min{n, m}} operatorname{Fib}_d^{(sum_{t = 1} ^ {lfloorfrac{min{n, m}}{d}
floor} mu left(t
ight) cdot lfloorfrac{n}{dt}
floor cdot lfloorfrac{m}{dt}
floor)}
]
换元。设 (T = dt),则有:
[ ext{原式} = prod_{d = 1} ^ {min{n, m}} operatorname{Fib}_d^{(sum_{t = 1} ^ {lfloorfrac{min{n, m}}{d}
floor} mu left(frac{T}{d}
ight) cdot lfloorfrac{n}{T}
floor cdot lfloorfrac{m}{T}
floor)}\
= prod_{d = 1} ^ {min{n, m}} (prod_{t = 1} ^ {lfloorfrac{min{n, m}}{d}
floor} operatorname{Fib}_d^{mu left(frac{T}{d}
ight)}) ^ {lfloorfrac{n}{T}
floor cdot lfloorfrac{m}{T}
floor}\
= prod_{T = 1} ^ {min{n, m}} (prod_{d | T} operatorname{Fib}_d ^ {mu left(frac{T}{d}
ight)})^{lfloorfrac{n}{T}
floor cdot lfloorfrac{m}{T}
floor}]
对于每个 (T), 预处理:
[prod_{d | T} operatorname{Fib}_d ^ {mu left(frac{T}{d}
ight)}
]
然后整除分块求解即可。