-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPP0272.cpp
More file actions
45 lines (43 loc) · 922 Bytes
/
CPP0272.cpp
File metadata and controls
45 lines (43 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <bits/stdc++.h>
#define MAX 10000001
#define ll long long
#define fastsync() \
ios_base::sync_with_stdio(0); \
cin.tie(NULL); \
cout.tie(NULL);
const int mod = 1e9 + 7;
using namespace std;
ll powmod(ll a, ll b) {
ll res = 1;
while (b) {
if (b & 1) {
res *= a;
res %= mod;
}
a *= a;
a %= mod;
b /= 2;
}
return res;
}
int main() {
fastsync();
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n];
ll tich = 1;
for (int &x : a) {
cin >> x;
tich = ((tich % mod) * (x % mod)) % mod;
}
int gcd = a[0];
for (int i = 1; i < n; i++) {
gcd = __gcd(gcd, a[i]);
}
cout << powmod(tich, gcd) << endl;
}
return 0;
}