樱花
题目链接:https://www.luogu.com.cn/problem/P1445
题解:
1
x
+
1
y
=
1
n
!
\frac{1}{x}+\frac{1}{y}=\frac{1}{n!}
x1+y1=n!1
=
>
x
+
y
x
y
=
1
n
!
=> \frac{x+y}{xy}=\frac{1}{n!}
=>xyx+y=n!1
=
>
x
y
=
x
∗
n
!
+
y
∗
n
!
=> xy = x*n!+y*n!
=>xy=x∗n!+y∗n!
=
>
y
(
x
−
n
!
)
=
x
∗
n
!
=>y(x-n!) = x*n!
=>y(x−n!)=x∗n!
=
>
y
=
x
∗
n
!
x
−
n
!
=>y = \frac{x*n!}{x-n!}
=>y=x−n!x∗n!
令
z
=
x
−
n
!
z = x-n!
z=x−n!,则
x
=
z
+
n
!
x = z+n!
x=z+n!
=
>
y
=
n
!
∗
(
z
+
n
!
)
z
=>y = \frac{n!*(z+n!)}{z}
=>y=zn!∗(z+n!)
=
>
y
=
n
!
+
n
!
∗
n
!
z
=>y = n!+\frac{n!*n!}{z}
=>y=n!+zn!∗n!
x
,
y
x,y
x,y都是正整数,则
n
!
∗
n
!
n!*n!
n!∗n!需能整除z,求
n
!
∗
n
!
n!*n!
n!∗n!的因数数量即可。
#include<stdio.h>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<iterator>
#define dbg(x) cout<<#x<<" = "<<x<<endl;
#define INF 0x3f3f3f3f
#define eps 1e-6
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int maxn = 1000100;
const int mod = 1000000007;
int a[maxn];
LL getnum(int n, int x);
int main()
{
int n, i, j, k;
LL ans = 1;
scanf("%d", &n);
for(i=2;i<=n;i++)
if(!a[i]){
for(j=i+i;j<=n;j+=i)
a[j] = 1;
LL num = 2*getnum(n, i)+1;
ans = ans*num%mod;
}
printf("%lld\n", ans);
return 0;
}
LL getnum(int n, int x)
{
LL res = 0;
while(n){
res += n/x;
n /= x;
}
return res;
}