题意
给n个数
求 d 的所有约数相积得到的数的相积
所以答案应该是
ans mod 1e9+7
思路
所以关键是对于k的 考虑
考虑每个数pi出现的次数为num[i]
先考虑其单个ki应该是num[i]*(num[i]+1)/2(出现0,1,2,…num[i])
但是如果考虑其他的
因此快速幂即可
ps: ki可能会很大
那么可以用费马小定理
小细节
mod-1和2是非互质的 所以可以将在给 k取模时 2 (% mod2-2 就是说)
这样后面转换过来不会有丢失(就是 后来再 mod-1)
本质是通用求逆元(b=2)
AC代码
#include<bits/stdc++.h>
#define endl "\n"
#define INF 0x3f3f3f3f3f3f3f
typedef long long ll;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
const double EI = exp(1.0);
const int N = 2e6 + 10;
const double eps = 1e-8;
using namespace std;
ll fast_pow(ll a, ll b)
{
ll ans = a, res = 1;
while (b>0)
{
if (b & 1)
res = (res * ans) % mod;
ans = (ans * ans) % mod;
b /= 2;
}
return res;
}
ll inv(ll x) { return fast_pow(x, mod - 2); }
void solve()
{
int n;
cin >> n;
map<ll, ll>M;
for (int i = 1; i <= n; i++)
{
int x;
cin >> x;
M[x]++;
}
ll d = 1;
for (auto t : M)
{
d = (d*(t.second + 1))%(2*mod-2);
}
ll ans = 1;
for (auto t : M)
{
ans = (ans * fast_pow(t.first, t.second * d / 2 % (2 * mod - 2)) % mod);
}
cout << ans << endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(); cout.tie(0);
//int t; cin >> t; while (t--)
solve();
return 0;
}