题面
已知
[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;
}