标签:ace #define bre cpp name AC tput rip prim
BZOJ_2721_[Violet 5]樱花_数学
$\frac{1}{x}+\frac{1}{y}=\frac{1}{m}$
$xm+ym=xy$
$(x-m)*(y-m)=m^{2}$
于是转化为了求$n!$的约数个数
可以用每个质因子搞一下
代码:
#include <stdio.h> #include <string.h> #include <algorithm> #include <stdlib.h> using namespace std; #define N 1000050 typedef long long ll; int n,prime[N],cnt; bool vis[N]; ll ans,mod=1000000007; int main() { ll i,j; ans=1; scanf("%d",&n); for(i=2;i<=n;i++) { if(!vis[i]) { prime[++cnt]=i; int tmp=n,r=0; //while(tmp) r+=tmp/i,tmp/=i; for(j=i;j>=i&&j<=n;j*=i) { r+=n/j; } ans=ans*(2*r+1)%mod; } for(j=1;j<=cnt&&i*prime[j]<=n;j++) { vis[i*prime[j]]=1; if(i%prime[j]==0) break; } } printf("%lld\n",ans); }
标签:ace #define bre cpp name AC tput rip prim
原文地址:https://www.cnblogs.com/suika/p/8967169.html