zoukankan      html  css  js  c++  java
  • P1445 [Violet]樱花 题解(推式子)

    题目链接

    题目思路

    \(1/x+1/y=1/n!\)\((x,y)\)的对数

    首先可以进行化简成为\((x+y)n!-xy=0\)

    对于这种问题肯定是想要化成质因子分解的形式的

    两边同时加上\(n!^2\)

    则化简为\((x-n!)(y-n!)=n!^2\)

    然后进行质因子分解即可

    代码

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<int,int> pii;
    #define fi first
    #define se second
    #define debug printf("aaaaaaaaaaa\n");
    const int maxn=1e6+5,inf=0x3f3f3f3f,mod=1e9+7,mul=233;
    const ll INF=0x3f3f3f3f3f3f3f3f;
    const double eps=1e-7;
    int n;
    int prime[maxn],cnt;
    int isprime[maxn];
    ll tot[maxn];
    void getprime(int n){
        for(ll i=2;i<=n;i++){//开ll因为后面要计算i*prime[j]
            if(!isprime[i]){
                prime[++cnt]=i;
                isprime[i]=i;
            }
            for(int j=1;j<=cnt&&i*prime[j]<=n;j++){
                isprime[i*prime[j]]=prime[j];
                if(i%prime[j]==0) break;
            }
        }
    }
    int main(){
        getprime(1000000);
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            int now=i;
            while(now!=1){
                tot[isprime[now]]+=2;
                now/=isprime[now];
    
            }
        }
        ll ans=1;
        for(int i=1;i<=n;i++){
            ans=ans*(tot[i]+1)%mod;
        }
        printf("%lld\n",ans);
        return 0;
    }
    
    
  • 相关阅读:
    postgresql删除活动链接的数据库
    第四篇 函数
    Jmeter响应中文乱码解决办法
    第三篇 条件控制和循环
    第二篇 Python运算符
    npm更换为镜像
    第一篇 Python的数据类型
    newman的常用命令使用总结
    windows下安装newman
    同态包络提取
  • 原文地址:https://www.cnblogs.com/hunxuewangzi/p/15547990.html
Copyright © 2011-2022 走看看