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;
}