[bzoj2721][Violet 5]樱花

2721: [Violet 5]樱花

Time Limit: 5 Sec   Memory Limit: 128 MB
[ Submit][ Status][ Discuss]

Description

Input

Output

Sample Input

Sample Output

HINT

Source

1/x + 1/y = 1/n!
因为x,y > 0
所以x,y > n!
设x = n! + a
1/(n!+a) + 1/y = 1/n!
y*n! + (n!+a)*n! = y*(n!+a)
y*a = (n!)^2 + a*n!
y = (n!)^2/a + n!
因为只有当a是(n!)^2的因数的时候,y是一个整数,且可以知道一个y被一个a唯一确定
所以答案就是(n!)^2的约数个数
一个数(p1^a1*p2^a2...pn^an)的约数个数就是(a1+1)*(a2+1)*...*(an+1)
然后如何计算n!对于pi的指数
加上n/pi,n/pi^2.....直到n<=pi^x
就完了
此题没有样例差评
#include<bits/stdc++.h>
using namespace std;
const int N = 1000000 + 6;
const int mod = 1000000000 + 7;
int n,pri[N],tot,ans=1; bool isnot[N];
void init( int x ){
	for( int i = 2; i <= x; i++ ){
		if( !isnot[i] ) pri[++tot] = i;
		for( int j = 1; j <= tot && i * pri[j] <= x; j++ ){
			isnot[i*pri[j]] = 1;
			if( i % pri[j] == 0 ) break;
		}
	}
}
int main(){
	scanf("%d", &n );
	init(n);
	for( int i = 1; i <= tot; i++ ){
		int tmp = n; long long cnt = 0;
		while( tmp ){
			cnt += tmp / pri[i], tmp /= pri[i];
		}
		cnt = 1LL * ( ( cnt << 1 ) + 1 ) % mod;
		ans = 1LL* ans * cnt % mod;
	}
	cout<<ans<<endl;
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值