比赛 20241129 评测结果 AAAAAAAAAA
题目名称 平方 最终得分 100
用户昵称 ┭┮﹏┭┮ 运行时间 1.993 s
代码语言 C++ 内存使用 6.42 MiB
提交时间 2024-11-29 11:35:15
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,ll>
#define fi first
#define in inline
#define se second
#define mp make_pair
#define pb push_back
const int N = 2e5+10;
const ll mod = 1e9+7;

ll read(){
	ll x = 0,f = 1;char c = getchar();
	for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
	for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
	return x * f;
}


int n;
ll a[N],s[1000010];
ll ksm(ll x,ll y){
	ll ans = 1;
	while(y){
		if(y & 1)ans = ans * x % mod;
		x = x * x % mod,y >>= 1;
	}return ans;
}

int main(){
	freopen("pingfang.in","r",stdin);
	freopen("pingfang.out","w",stdout);
	n = read();
	for(int i = 1;i <= n;i++){
		a[i] = read();
		int mx = sqrt(a[i]);
		for(int j = 2;j <= mx;j++){
			if(a[i] % j)continue;
			int cnt = 0;
			while(a[i] % j == 0)a[i] /= j,cnt++;
			if(cnt % 2)s[j]++;
		}
		if(a[i] > 1)s[a[i]]++;
	}
	ll ans = 1;
	for(int i = 2;i < 1000000;i++)ans = ans * ksm((ll)i,min(s[i],n - s[i])) % mod;
	printf("%lld\n",ans);

	return 0;

}