QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#567799 | #5062. Square | H_ZzZ# | WA | 9ms | 16844kb | C++20 | 1.3kb | 2024-09-16 13:58:18 | 2024-09-16 13:58:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int N=1e6+50,mod=1e9+7;
int a[N],t[N];
int primes[N],dv[N],cnt;
bool st[N];
void init()
{
int n=1e6+5;
for(int i=2;i<=n;i++)
{
if(!st[i])primes[++cnt]=i,dv[i]=1;
for(int j=1;primes[j]*i<=n;j++)
{
st[primes[j]*i]=true;
dv[primes[j]*i]=i;
if(i%primes[j]==0)break;
}
}
}
int qmi(int a,int b)
{
int res=1;
while(b)
{
if(b&1)res=res*a%mod;
a=a*a%mod;
b>>=1;
}
return res;
}
void solve()
{
init();
int n;
cin>>n;
map<int,int> mp;
for(int i=1;i<=n;i++)cin>>a[i];
map<int,int> t;
for(int i=1;i<=n;i++)
{
map<int,bool> has;
while(a[i]!=1)
{
int x=a[i]/dv[a[i]];
a[i]=dv[a[i]];
if(!has[x])t[x]++,has[x]=true;
}
}
int ans=1;
for(auto [x,y]:t)
{
y = min(y,n-y);
ans=ans*qmi(x,y)%mod;
}
cout<<ans;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int T=1;
//cin >> T;
while(T--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 16472kb
input:
3 2 3 6
output:
6
result:
ok 1 number(s): "6"
Test #2:
score: 0
Accepted
time: 3ms
memory: 15416kb
input:
1 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 9ms
memory: 15112kb
input:
100000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 4ms
memory: 16068kb
input:
1000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 4ms
memory: 16468kb
input:
1 130321
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 3ms
memory: 16204kb
input:
1 85849
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: 0
Accepted
time: 8ms
memory: 16844kb
input:
10 1 37249 1 193 1 193 193 193 1 37249
output:
387487994
result:
ok 1 number(s): "387487994"
Test #8:
score: -100
Wrong Answer
time: 4ms
memory: 15348kb
input:
10 130321 130321 6859 6859 6859 19 19 130321 361 6859
output:
1
result:
wrong answer 1st numbers differ - expected: '130321', found: '1'