zoukankan      html  css  js  c++  java
  • 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;
    }
    
  • 相关阅读:
    python数据分析之ipython
    Django之文件下载
    mongodb学习之:主从复制
    Django之高级视图与URL
    Django之request对象
    tornado安全应用之用户认证
    tornado安全应用之cookie
    tornado之异步web服务二
    【原创】Linux基础之测试域名IP端口连通性
    【原创】大数据基础之Mesos+Marathon+Docker部署nginx
  • 原文地址:https://www.cnblogs.com/cj-xxz/p/10185337.html
Copyright © 2011-2022 走看看