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\n", ans);
	return 0;
}
posted @ 2018-12-27 15:40  xgzc  阅读(146)  评论(0编辑  收藏  举报