http://codeforces.com/contest/615/problem/D
Ayrat has number n, represented as it's prime factorization pi of size m, i.e. n = p1·p2·...·pm. Ayrat got secret information that that the product of all divisors of n taken modulo 109 + 7 is the password to the secret data base. Now he wants to calculate this value.
The first line of the input contains a single integer m (1 ≤ m ≤ 200 000) — the number of primes in factorization of n.
The second line contains m primes numbers pi (2 ≤ pi ≤ 200 000).
Print one integer — the product of all divisors of n modulo 109 + 7.
2
2 3
36
3
2 3 2
1728
In the first sample n = 2·3 = 6. The divisors of 6 are 1, 2, 3 and 6, their product is equal to 1·2·3·6 = 36.
In the second sample 2·3·2 = 12. The divisors of 12 are 1, 2, 3, 4, 6 and 12. 1·2·3·4·6·12 = 1728.
题意很简洁
给你一个数的所有质因数,然后让你求出这个数所有因数的乘积
那么到此,问题就解决了
我们梳理一下步骤:
1、求sum =(t[1]+1)(t[2]+1).....(t[n]+1)%(2(mod-1))
2、对每个i,ans=ans* i^( sum*t[i]/2%(mod-1) ) %mod;
#include <cstdio> #include <cmath> #include <cstring> #include <string> #include <algorithm> #include <iostream> #include <queue> #include <map> #include <set> #include <vector> #include<stack> using namespace std; __int64 mod=1e9+7; __int64 pow_m(__int64 a,__int64 b,__int64 c) { __int64 ans=1; __int64 tmp=a; while(b) { if (b&1) ans=ans*tmp%c; //不可以写 ans=ans*ans%c 结果会变 tmp=tmp*tmp%c; b=b>>1; } return ans; } __int64 tm[200005]; int main() { int n; __int64 i,x; cin>>n; __int64 j; for( j=1;j<=n;j++) { scanf("%I64d",&x); tm[x]++; } __int64 sum=1; for (i=1;i<=200000;i++) if (tm[i]) sum=sum*(tm[i]+1)%(2*mod-2); __int64 ans=1; for (i=1;i<=200000;i++) if (tm[i]) ans=ans*pow_m(i, sum*tm[i]/2%(mod-1) ,mod)%mod; printf("%I64d\n",ans%mod); return 0; }