Luogu1445 [Violet]樱花
Posted cj-xxz
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Luogu1445 [Violet]樱花相关的知识,希望对你有一定的参考价值。
题面
题解
$$ frac 1x + frac 1y = frac 1{n!} \ frac{x+y}{xy}=frac 1{n!} \ xy=n!(x+y) \ xy-n!(x+y)=0 \ (x-n!)(y-n!)=(n!)^2 \ $$
因为确定$(x-n!),(y-n!)$就能确定$x,y$,所以答案就是$d((n!)^2)$
代码
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define RG register
#define file(x) freopen(#x".in", "r", stdin);freopen(#x".out", "w", stdout);
#define clear(x, y) memset(x, y, sizeof(x))
inline int read()
{
int data = 0, w = 1; char ch = getchar();
while(ch != ‘-‘ && (!isdigit(ch))) ch = getchar();
if(ch == ‘-‘) w = -1, ch = getchar();
while(isdigit(ch)) data = data * 10 + (ch ^ 48), ch = getchar();
return data * w;
}
const int maxn(10000010), Mod(1e9 + 7);
int n, prime[maxn], cnt;
long long c[maxn];
bool not_prime[maxn];
void init()
{
not_prime[1] = true;
for(RG int i = 2; i <= n; i++)
{
if(!not_prime[i]) prime[++cnt] = i;
for(RG int j = 1; j <= cnt && i * prime[j] <= n; j++)
{
not_prime[i * prime[j]] = true;
if(!(i % prime[j])) break;
}
}
}
int main()
{
#ifndef ONLINE_JUDGE
file(cpp);
#endif
n = read(); init();
for(RG int i = 1; i <= cnt; i++)
{
int p = prime[i];
for(RG long long j = p; j <= n; j *= p) c[i] += (n / j);
c[i] %= Mod;
}
long long ans = 1;
for(RG int i = 1; i <= cnt; i++) ans = ans * (c[i] << 1 | 1) % Mod;
printf("%lld
", ans);
return 0;
}
以上是关于Luogu1445 [Violet]樱花的主要内容,如果未能解决你的问题,请参考以下文章