LUOGU1445——没占到1444的愤怒 数学

1445

题意:给定n,求1/x+1/y=1/n!的正整数解的数量


先对原式分解一下

(x+y)/xy=1/n!

xy-(x+y)*n!=0

(n!)^2+xy-(x+y)*n!=(n!)^2

(x-n!)*(y-n!)=(n!)^2

因为x,y为任意正整数,所以x-n!和y-n!也可以是任意正整数

所以题意转化为->x*y=(n!)^2


那么我们对n!分解质因数


然后我们考虑x的取值,显然,若一个质数p有k个,那么x可以取p^0,p^1....p^k

共(k+1)种情况

乘法原理乘起来就可以了

而且显然,x确定后,y必然也会被确定

CODE:

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
#include <cstring>
#include <ctime>
#include <vector>
#define inf 1e9
#define ll long long
#define For(i,j,k) for(ll i=j;i<=k;i++)
#define Dow(i,j,k) for(ll i=k;i>=j;i--)
using namespace std;
inline void read(ll &tx){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  tx=x*f; }
inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  }
inline void writeln(ll x){write(x);puts("");}
using namespace std;
ll n,ans,cnt[3000001],last[3000001],pri[3000001],tot;
ll mo=1e9+7;
bool bj[3000001];
inline void get_pri()
{
    For(i,2,n)
    {
        if(!bj[i]){pri[++tot]=i;last[i]=tot;}
        For(j,1,tot)
        {
            if(i*pri[j]>n)    break;
            bj[i*pri[j]]=1;
            last[i*pri[j]]=j;
            if(i%pri[j]==0)    break;
        }
    }
}
inline void fj(ll x)
{
    while(x!=1)
    {
        cnt[last[x]]++;cnt[last[x]]%=mo;
        x/=pri[last[x]];
    }
    
}
int  main()
{
    read(n);
    get_pri();
    For(i,2,n)
        fj(i);
    For(i,1,tot)    cnt[i]*=2LL,cnt[i]%=mo;
    ans=1;
    For(i,1,tot)
        ans=ans*(cnt[i]+1)%mo;
    writeln(ans);
    system("pause");
}
     


  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值