QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#527953 | #5062. Square | Hadtsti | WA | 26ms | 23092kb | C++14 | 1.2kb | 2024-08-23 00:13:43 | 2024-08-23 00:13:43 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
int n,x,ans=1;
int p[1010],cnt;
bitset<1010>S;
unordered_map<int,int>v[100010];
unordered_map<int,vector<int> >T;
int power(int a,int b)
{
int res=1;
for(;b;b>>=1)
{
if(b&1)
res=1ll*res*a%mod;
a=1ll*a*a%mod;
}
return res;
}
int main()
{
for(int i=2;i<=1000;i++)
if(!S[i])
{
p[++cnt]=i;
for(int j=i;j<=1000/i;j++)
S[i*j]=1;
}
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&x);
for(int j=1;j<=cnt&&p[j]<=x/p[j];j++)
if(x%p[j]==0)
{
int ct=0;
while(x%p[j]==0)
{
ct++;
x/=p[j];
}
v[i][p[j]]=ct;
}
if(x>1)
v[i][x]=1;
}
for(int i=1;i<n;i++)
for(pair<int,int>j:v[i])
if(j.second)
{
if(i>1&&(!v[i-1][j.first])&&(j.second&1))
T[j.first].push_back(i-1);
if(j.second+v[i+1][j.first]&1)
T[j.first].push_back(i);
}
for(pair<int,vector<int> >i:T)
{
int w=1,sum=0;
for(int j=1;j<i.second.size();j++)
{
w^=1;
if(!w)
sum+=i.second[j]-i.second[j-1];
}
if(w)
sum+=n-i.second.back();
ans=1ll*ans*power(i.first,min(sum,n-sum))%mod;
}
printf("%d",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 9268kb
input:
3 2 3 6
output:
6
result:
ok 1 number(s): "6"
Test #2:
score: 0
Accepted
time: 2ms
memory: 9272kb
input:
1 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 3ms
memory: 9204kb
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: 3ms
memory: 9292kb
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: 3ms
memory: 9236kb
input:
1 130321
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 0ms
memory: 9268kb
input:
1 85849
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: 0
Accepted
time: 2ms
memory: 9516kb
input:
10 1 37249 1 193 1 193 193 193 1 37249
output:
387487994
result:
ok 1 number(s): "387487994"
Test #8:
score: 0
Accepted
time: 2ms
memory: 9260kb
input:
10 130321 130321 6859 6859 6859 19 19 130321 361 6859
output:
130321
result:
ok 1 number(s): "130321"
Test #9:
score: 0
Accepted
time: 2ms
memory: 9340kb
input:
10 1 418609 1 418609 1 1 647 418609 1 1
output:
647
result:
ok 1 number(s): "647"
Test #10:
score: 0
Accepted
time: 3ms
memory: 9256kb
input:
10 85849 293 1 293 1 1 85849 293 293 293
output:
424869580
result:
ok 1 number(s): "424869580"
Test #11:
score: 0
Accepted
time: 2ms
memory: 9276kb
input:
10 16384 2048 8192 512 65536 524288 65536 4 2 262144
output:
32
result:
ok 1 number(s): "32"
Test #12:
score: 0
Accepted
time: 24ms
memory: 22736kb
input:
100000 1 197 1 38809 197 197 38809 1 197 197 1 38809 38809 1 1 1 1 38809 197 1 1 1 1 38809 197 197 1 38809 1 1 38809 38809 1 197 1 197 38809 38809 197 197 38809 1 38809 38809 197 38809 38809 197 197 1 38809 38809 38809 38809 38809 197 38809 38809 197 1 1 197 38809 38809 38809 197 1 1 1 197 197 197 1...
output:
810775411
result:
ok 1 number(s): "810775411"
Test #13:
score: -100
Wrong Answer
time: 26ms
memory: 23092kb
input:
100000 1 1 597529 773 1 597529 1 773 1 597529 773 773 597529 773 597529 1 597529 773 773 1 1 597529 597529 773 773 597529 1 597529 1 1 773 773 1 597529 597529 597529 597529 597529 597529 773 597529 773 1 773 597529 773 1 1 773 773 773 597529 597529 1 1 773 773 773 773 597529 597529 597529 773 773 77...
output:
956942036
result:
wrong answer 1st numbers differ - expected: '716188655', found: '956942036'