zoukankan      html  css  js  c++  java
  • 洛谷 P3704 SDOI2017 数字表格

    题意:

    给定两个整数 (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)} ]

    然后整除分块求解即可。

  • 相关阅读:
    1052. 卖个萌 (20)
    1051. 复数乘法 (15)
    1050. 螺旋矩阵(25)
    1049. 数列的片段和(20)
    1048. 数字加密(20)
    1047. 编程团体赛(20)
    1046. 划拳(15)
    怎么用js代码改变单选框的选中状态
    Dom操作--全选反选
    Scoket简介
  • 原文地址:https://www.cnblogs.com/zimujun/p/14348299.html
Copyright © 2011-2022 走看看