QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#738996#9619. 乘积,欧拉函数,求和ucup-team4975#WA 2ms3648kbC++141.6kb2024-11-12 20:29:362024-11-12 20:29:44

Judging History

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

  • [2024-11-12 20:29:44]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3648kb
  • [2024-11-12 20:29:36]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int P=998244353;
using ll = long long;
const ll inf = 2e15;
const int N=2005;
int p[N];
int cnt;
int a[N];
int b[N];
int ans=1;
int nowans=1;
int n;
int qpow(int a,int b) {
    int ret=1;
    while(b) {
        if(b&1) ret=ret*a%P;
        a=a*a%P;
        b>>=1;
    }
    return ret;
}
int inv(int a) {return qpow(a,P-2);}
void solve() {
    for(int i=2;i<=3000;i++) {
        int isP=1;
        for(int j=2;j<i;j++) {
            if(i%j==0) {
                isP=0;
                break;
            }
        }
        if(isP==1) p[++cnt]=i;
    }
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        ans = ans * inv(i) % P;
    }
    for(int j=1;j<=cnt;j++) {
        for(int i=1;i<=n;i++) {
            b[i]=1;
            while(a[i]%p[j]) {
                a[i]/=p[j];
                b[i]*=p[j];
            }
        }
        sort(b+1,b+n+1);
        if(b[n]==1) continue;
        int x=0;
        for(int i=1;i<=n;i++) {
            if(b[i]!=1) {
                x=i-1;
                break;
            }
        }
        int nowans1=qpow(2,x);
        nowans=1;
        for(int i=x+1;i<=n;i++) {
            nowans=nowans*(1+b[i])%P;
            nowans-=1;
            nowans=nowans*(p[j]-1)%P*inv(p[j])%P*qpow(2,x)%P;
        }
        //if(p[j]==3) cout<<nowans<<endl;
        ans=ans*nowans%P;
    }
    cout<<ans<<endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    // cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3648kb

input:

5
1 6 8 6 2

output:

788295121

result:

wrong answer 1st lines differ - expected: '892', found: '788295121'