# Product

Accepts: 21

Submissions: 171
Time Limit: 6000/3000 MS (Java/Others)

Memory Limit: 131072/131072 K (Java/Others)

给n个数{A}_{1},{A}_{2}....{A}_{n}，表示N=\prod_{i=1}^{n}{i}^{{A}_{i}}。求N所有约数之积。

输入有多组数据.

对于每组数据输出一行为答案对{10}^{9}+7取模的值.

4
0 1 1 0
5
1 2 3 4 5

36
473272463

#pragma warning(disable:4996)
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
using namespace std;

typedef long long ll;

ll N;
const int maxn = 100010;
const ll mod = 1e9 + 7;
const ll mod2 = 2 * (mod - 1);
ll index[maxn], L[maxn], R[maxn];
int num, pri[maxn], vis[maxn];
vector<int>have[maxn];

void init()
{
num = 0;
int i, j, n;
for (i = 2; i < maxn; i++)
{
if (vis[i])
continue;
pri[++num] = i;
for (j = i + i; j < maxn; j = j + i)
{
vis[j] = 1;
}
}
for (i = 1; i < maxn; i++)
{
n = i;
for (j = 1; j <= num&&pri[j] <= n; j++)
{
while (n%pri[j] == 0)
{
have[i].push_back(j);//记录所含有的质数，用质数的下标记录
n /= pri[j];
}
}
}
}

ll getresult(ll A, ll n, ll k)
{
ll b = 1;
while (n > 0)
{
if (n & 1)
{
b = (b*A) % k;
}
n = n >> 1;
A = (A*A) % k;
}
return b;
}

void solve(int cishu, int n)
{
int temp;
int si = have[cishu].size();
for (int i = 0; i < si; i++)
{
temp = have[cishu][i];
index[temp] = (index[temp] + n) % mod2;
}
}

int main()
{
//freopen("i.txt", "r", stdin);
//freopen("o.txt", "w", stdout);

int x;
ll k, n, ans;
init();
while (scanf("%d", &N) == 1)
{
memset(index, 0, sizeof(index));
for (int i = 1; i <= N; i++)
{
scanf("%d", &x);
solve(i, x);
}
int p = 1;
while (pri[p] < N)
p++;
N = p;
L[0] = R[N + 1] = 1;
for (int i = 1; i <= N; i++)
L[i] = L[i - 1] * (index[i] + 1) % mod2;
for (int i = N; i >= 1; i--)
R[i] = R[i + 1] * (index[i] + 1) % mod2;
ans = 1;
for (int i = 1; i <= N; i++)
{
k = L[i - 1] * R[i + 1] % mod2;
n = index[i] * (index[i] + 1) / 2 % mod2;
ans = ans*getresult(pri[i], n*k%mod2,mod) % mod;
}
printf("%lld\n", ans);
}
//system("pause");
return 0;
}

#### HDU 1395(欧拉定理)

2014-01-17 23:42:31

#### HDU 3221 Brute-force Algorithm(欧拉公式降幂）

2015-09-22 14:42:29

#### 2016多校训练一 PowMod，hdu5728（欧拉函数+指数循环节）

2016-07-20 13:22:02

#### 欧拉定理与应用

2014-04-21 21:15:13

#### 扩展欧拉定理

2017-07-27 11:03:14

#### 欧拉定理，费马小定理证明

2016-08-17 22:14:30

#### 拓展欧拉定理总结

2017-10-23 22:14:42

#### 欧拉定理ext证明[转自知乎]

2017-07-09 22:12:16

#### 扩展欧拉定理的证明 欧拉定理的推广

2017-11-29 11:00:12

#### 逆元 + 费马定理 + 欧拉定理

2015-08-26 09:33:34