Bzoj 2721 [Violet 5]樱花 [数论]

2721: [Violet 5]樱花

Time Limit: 5 Sec   Memory Limit: 128 MB
Submit: 648   Solved: 380

Description

Input

Output

Sample Input

Sample Output

HINT

Source

[ Submit][ Status][ Discuss]


这道题要用到唯一分解定理和约数个数定理
因为
1 / x  +  1 / y  =  1 / n!
所以 1 / x < 1 / n!  且 1 / y < 1 / n!  =>  x > n! 且 y > n!
设 y = n! + d
原式可推得
x = (n!) ^ 2 / d  + n!
即要求 (n!)的约数个数
唯一分解一个数x = p1 ^ a1 * p2 ^ a2 * p3 ^ a3 ..... pk ^ ak
他的约数个数为  num = (a1 + 1) * (a2 + 1) * (a3 + 1).......(ak +1)裸乘法原理.....

/**************************************************************
    Problem: 2721
    User:
    Language: C++
    Result: Accepted
    Time:72 ms
    Memory:6172 kb
****************************************************************/
 
#include <bits/stdc++.h>
using namespace std;
 
const int N = 1e6 + 137, mod = 1e9 + 7;
 
int pri[N], tot;
bool isp[N];
 
void Linear_Shaker( int n )
{
    for(int i = 2; i <= n; ++i)
    {
        if(!isp[i]) pri[++tot] = i;
        for(int j = 1; j <= tot && pri[j] * i <= n; ++j)
        {
            isp[pri[j] * i] = 1;
            if(i % pri[j] == 0) break;
        }
    }
}
 
int n;
 
int main()
{
    cin >> n;
    Linear_Shaker(n);
    int ans = 1;
    for(int i = 1; i <= tot; ++i)
    {
        int tmp = n, cnt = 0;
        while(tmp)
            cnt += tmp / pri[i], tmp /= pri[i];
        cnt = (cnt << 1 | 1);
        ans = 1LL * ans * cnt % mod;
    }
    cout << ans << endl;
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值