• 「BZOJ4173」数学


    题面

    已知

    [large{S(n,m)={k_{1},k_{2},cdots k_{i}}} ]

    且每个 (k) 满足

    [large{n \%k+m\%kgeq k} ]

    [large{phi(n) imes phi(m) imessum_{kin S(n,m) }phi(k)\%998244353} ]

    Part 1

    [large{n=a_{1} imes k +b_{1} ,m=a_{2} imes k +b_{2}} ]

    所以有

    [large{b_{1}+b_{2} geq k} ]

    [large{(a_{1} imes k +b_{1})+(a_{2} imes k +b_{2}) geq (a_{1}+a_{2}+1) imes k} ]

    所以

    [large{n+m geq (a_{1}+a_{2}+1) imes k} ]

    两边同时除以 (k) 并向下取整得

    [large{lfloor frac{n+m}{k} floor geq a_{1}+a_{2}+1} ]

    因为

    [large{a_{1}=lfloor frac{n}{k} floor ,a_{2}=lfloor frac{m}{k} floor} ]

    所以

    [large{lfloor frac{n+m}{k} floor geq lfloor frac{n}{k} floor+lfloor frac{m}{k} floor+1} ]

    [large{lfloor frac{n+m}{k} floor - lfloor frac{n}{k} floor - lfloor frac{m}{k} floorgeq 1} ]

    已知

    [large{lfloorfrac{x}{y} floor=frac{x}{y}-{frac{x}{y}}} ]

    所以式子可化为

    [large{frac{n+m}{k}-{frac{n+m}{k}}-(frac{n}{k}-{frac{n}{k}}+frac{m}{k}-{frac{m}{k}})} geq 1 ]

    化简得

    [large{{frac{n}{k}}+{frac{m}{k}}-{frac{n+m}{k}}}geq 1 ]

    因为

    [large{0leq{frac{n}{k}}},{frac{m}{k}},{frac{n+m}{k}}<1 ]

    所以

    [large{1<{frac{n}{k}}}+{frac{m}{k}}-{frac{n+m}{k}}<2 ]

    又因为

    [large{{frac{n}{k}}+{frac{m}{k}}-{frac{n+m}{k}}}geq 1,{frac{n}{k}}+{frac{m}{k}}-{frac{n+m}{k}}in N^{+} ]

    所以

    [large{{frac{n}{k}}+{frac{m}{k}}-{frac{n+m}{k}}}= 1 ]

    [large{lfloor frac{n+m}{k} floor - lfloor frac{n}{k} floor - lfloor frac{m}{k} floor= 1} ]

    Part2

    先忽视要求式子的部分, 得

    [large{sum_{kin S(n,m)}phi(k)} ]

    [large{sum_{n \%k+m\%kgeq k }phi(k)} ]

    [large{sum_{k=1}^{n+m}phi(k) imeslfloor frac{n+m}{k} floor}-sum_{k=1}^{n}phi(k) imeslfloor frac{n}{k} floor-sum_{k=1}^{m}phi(k) imeslfloor frac{m}{k} floor ]

    因为

    [large{n=sum_{d|n}phi(d)} ]

    所以

    [large{sum_{i=1}^{n+m}i-sum_{i=1}^{n}i-sum_{i=1}^{m}i=frac{(n+m) imes(n+m-1)}{2}-frac{n imes(n-1)}{2}-frac{m imes(m-1)}{2}-} ]

    [large{=n imes m} ]

    结论

    [large{ans=large{phi(n) imes phi(m) imes n imes m\%998244353}} ]

    代码

    #include <bits/stdc++.h>
    using namespace std;
    
    const int mod=998244353;
    
    unsigned long long n,m;
    
    unsigned long long phi(unsigned long long x)
      {
        unsigned long long ans=x;
        for (unsigned long long i=2;i*i<=x;i++)
          {
            if (x%i==0)
              {
                ans-=ans/i;
                while (x%i==0) x/=i;
              }
          }
        if (x>1) ans-=ans/x;
        return ans%mod;
      }
    
    int main()
      {
        cin>>n>>m;
        cout<<(phi(n)%mod)*(phi(m)%mod)%mod*(n%mod)%mod*(m%mod)%mod;
        return 0;
      }
    
  • 相关阅读:
    转《编程之美——微软技术面试心得》勘误表
    第一次 学习使用 智能指针
    test _todel
    (转 todo阅读)Android 官方博客 Android应用程序的内存分析(翻译)
    msdn snmp trap 研究可否 重入 转《Multiple Trap Registrations》
    wpbars在博客园开博客了
    创业失败的10个教训总结
    winform 的一种登录方法。
    快速建立Subversion
    (转)SQL Server 按某一字段分组取最大(小)值所在行的数据
  • 原文地址:https://www.cnblogs.com/666DHG/p/Solution_001.html
Copyright © 2020-2023  润新知