BZOJ 2721: [Violet 5]樱花

(X-N)(Y-N)=N^2

#include<cstdio>
using namespace std;
const int mod=1e9+7;
int n,cnt,isprime[1000005],prime[1000005];
void Pre_prime(){
	for (int i=2; i<=n; i++){
		if (!isprime[i]) prime[++cnt]=i;
		for (int j=1; j<=cnt && i*prime[j]<=n; j++){
			isprime[i*prime[j]]=1;
			if (i%prime[j]==0) break;
		}
	}
}
int main(){
	scanf("%d",&n);
	Pre_prime();
	int ANS=1;
	for (int i=1; i<=cnt; i++){
		long long x=prime[i];
		long long sum=0;
		while (x<=n){
			sum+=n/x;
			x*=prime[i];
		}
		ANS=1ll*ANS*(sum*2+1)%mod;
	}
	printf("%d\n",ANS);
	return 0;
}

  

posted @ 2018-10-18 17:45  ~Silent  阅读(128)  评论(0编辑  收藏  举报
Live2D