您的位置:首页 > 其它

【Violet 5】【BZOJ2721】樱花

2015-11-03 07:59 387 查看
Description



Input



Output



Sample Input

3

Sample Output

9

HINT



Source

interviewstreet–EQUATIONS

我良心的在这里给泥萌加上了样例>_<

SD2015省队集训Week1的测试题

首先显然x>n!,y>n!,那么我们选择令y=n!+z

则显然有x=n!2z+n!

求出n!2的约数个数就行了

答案记得开longlong,中间过程会炸

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define MAXN 1000010
#define P 1000000007
using namespace std;
int n;
long long ans=1;
int prime[MAXN],top,fac[MAXN];
bool not_prime[MAXN];
int cnt[MAXN];
void check_prime()
{
for (int i=2;i<=n;i++)
{
if (!not_prime[i])  prime[++top]=i,fac[i]=top;
for (int j=1;j<=top&&i*prime[j]<=n;j++)
{
not_prime[i*prime[j]]=1;fac[i*prime[j]]=j;
if (i%prime[j]==0)  break;
}
}
}
void calc(int x)
{
while (x!=1)    cnt[fac[x]]++,x/=prime[fac[x]];
}
int main()
{
scanf("%d",&n);
check_prime();
for (int i=1;i<=n;i++)  calc(i);
for (int i=1;i<=top;i++)    ans=ans*((2*cnt[i]+1)%P)%P;
cout<<ans<<endl;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  数论