比赛 |
noip |
评测结果 |
AAAAAAAAAAAAAAAAAAAA |
题目名称 |
__完全平方数 |
最终得分 |
100 |
用户昵称 |
yhf_2015 |
运行时间 |
2.266 s |
代码语言 |
C++ |
内存使用 |
89.64 MiB |
提交时间 |
2016-11-04 19:09:56 |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const int p = 1e8+7;
int prime[5000010], cnt;
bool is[5000010];
ll left1[5000010];
int pri_min[5000010];
ll pri_num[5000010];
ll n, ans = 1;
ll pow(ll a, ll b){
ll ans = 1;
for( ; b; b>>=1,a=(a*a)%p) if(b&1) ans = (ans*a)%p;
return ans;
}
int main(){
freopen("xnumber.in","r",stdin);
freopen("xnumber.out","w",stdout);
cin >> n;
is[0] = is[1] = 1;
for(register int i = 2; i <= n; i ++){
if(!is[i]) prime[++cnt] = i, pri_min[i] = cnt;
for(register int j = 1; j <= cnt; j ++){
if(prime[j]*i > n) break;
is[prime[j]*i] = 1;
pri_min[prime[j]*i] = j;
if(i%prime[j] == 0) break;
}
}
for(int i = 2; i <= n; i ++) left1[i] = 1;
for(int i = n; i >= 2; i --){
ll t = i;
pri_num[pri_min[t]] += left1[t];
left1[t/prime[pri_min[t]]] += left1[t];
}
for(int i = 1; i <= cnt; i ++){
ans = (ans*pow(prime[i],pri_num[i]/2))%p;
}
printf("%I64d", (ans*ans)%p);
return 0;
}