QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#567799#5062. SquareH_ZzZ#WA 9ms16844kbC++201.3kb2024-09-16 13:58:182024-09-16 13:58:18

Judging History

你现在查看的是最新测评结果

  • [2024-09-16 13:58:18]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:16844kb
  • [2024-09-16 13:58:18]
  • 提交

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;
}

詳細信息

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'