Product
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Problem Description
Given a number sequence A1,A2....An,indicating N=∏ni=1iAi.What is the product of all the divisors of N?
Input
There are multiple test cases.
First line of each case contains a single integer n.(1≤n≤105)
Next line contains n integers A1,A2....An,it's guaranteed not all Ai=0.(0≤Ai≤105).
It's guaranteed that ∑n≤500000.
First line of each case contains a single integer n.(1≤n≤105)
Next line contains n integers A1,A2....An,it's guaranteed not all Ai=0.(0≤Ai≤105).
It's guaranteed that ∑n≤500000.
Output
For each test case, please print the answer module 109+7 in a line.
Sample Input
4
0 1 1 0
5
1 2 3 4 5
Sample Output
36
473272463
Source
题意:
#pragma comment(linker, "/STACK:1024000000,1024000000") #include<iostream> #include<cstdio> #include<cmath> #include<string> #include<queue> #include<algorithm> #include<stack> #include<cstring> #include<vector> #include<list> #include<set> #include<map> using namespace std; #define ll long long #define pi (4*atan(1.0)) #define eps 1e-14 #define bug(x) cout<<"bug"<<x<<endl; const int N=2e5+10,M=4e6+10,inf=2147483647; const ll INF=1e18+10,mod=1e9+7; /// 数组大小 int prime(int n) { if(n<=1) return 0; if(n==2) return 1; if(n%2==0) return 0; int k, upperBound=n/2; for(k=3; k<=upperBound; k+=2) { upperBound=n/k; if(n%k==0) return 0; } return 1; } vector<int>p; int si[N]; void init() { for(int i=2;i<=100000;i++) if(prime(i)) p.push_back(i); } ll quick(ll a,ll b,ll c) { ll ans=1; while(b) { if(b&1)ans=(ans*a)%c; b>>=1; a=(a*a)%c; } return ans; } int main() { init(); int n; while(~scanf("%d",&n)) { memset(si,0,sizeof(si)); for(int i=1;i<=n;i++) { int z; int x=i; scanf("%d",&z); for(int j=0;j<p.size();j++) { if(1LL*p[j]*p[j]>x)break; if(x==1)break; while(x%p[j]==0) { si[j]+=z; si[j]=(si[j])%(2*(mod-1)); x/=p[j]; } } if(x!=1) { int pos=lower_bound(p.begin(),p.end(),x)-p.begin(); si[pos]+=z; } } ll sum=1; for(int i=0;i<p.size();i++) { sum*=(si[i]+1); sum%=(2*(mod-1)); } //cout<<sum<<endl; ll ans=1; for(int i=0;i<p.size();i++) { ans=(ans*quick(p[i],((sum*si[i])%(2*(mod-1)))/2,mod))%(mod); } printf("%lld ",ans); } return 0; }