QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#738670#9619. 乘积,欧拉函数,求和rotcar07WA 103ms4520kbC++231.3kb2024-11-12 19:40:452024-11-12 19:40:53

Judging History

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

  • [2024-11-12 19:40:53]
  • 评测
  • 测评结果:WA
  • 用时:103ms
  • 内存:4520kb
  • [2024-11-12 19:40:45]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll mod=998244353;
constexpr int pr[16]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47},ipr[16]={499122177, 665496236, 399297742, 142606337, 725995894, 537516191, 58720257, 893166001, 781234712, 516333287, 869438631, 755428160, 900854661, 487514685, 807091180};
constexpr int N=1<<15;
ll f[N],g[N];
vector<int> w[3005];
int a[2005],n,msk[2005],mx;
ll sb[N];
int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        int x=a[i],y=0;
        for(int i=0;i<15;i++)if(x%pr[i]==0){
            while(x%pr[i]==0) x/=pr[i];
            y|=1<<i;
        }
        if(x==2809) x=53;
        msk[i]=y;w[x].push_back(i);
    }
    f[0]=1;
    for(int _=1;_<=3000;_++)if(!w[_].empty()){
        memset(g,0,sizeof g);
        for(int i:w[_]){
            int sk=msk[i],val=a[i],vv=(_==1?a[i]:a[i]/_*(_-1));
            for(int i=N-1;i>=0;i--) g[i|sk]=(g[i|sk]+g[i]*val+f[i]*vv)%mod;   
        }
        for(int i=0;i<N;i++) f[i]=(f[i]+g[i])%mod;
    }
    ll ans=f[0];sb[0]=1;
    for(int i=1;i<N;i++){
        int z=__builtin_ctz(i);sb[i]=sb[i^1<<z]*ipr[z]%mod;
        ans+=f[i]*sb[i]%mod;
    }
    cout<<ans<<'\n';
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 4404kb

input:

5
1 6 8 6 2

output:

892

result:

ok single line: '892'

Test #2:

score: 0
Accepted
time: 0ms
memory: 4372kb

input:

5
3 8 3 7 8

output:

3157

result:

ok single line: '3157'

Test #3:

score: -100
Wrong Answer
time: 103ms
memory: 4520kb

input:

2000
79 1 1 1 1 1 1 2803 1 1 1 1 1 1 1609 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2137 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 613 1 499 1 211 1 2927 1 1 1327 1 1 1123 1 907 1 2543 1 1 1 311 2683 1 1 1 1 2963 1 1 1 641 761 1 1 1 1 1 1 1 1 1 1 1 1489 2857 1 1 1 1 1 1 1 1 1 1 1 1 1 967 1 821 1 1 1 1 2143 1861...

output:

2038465934478

result:

wrong answer 1st lines differ - expected: '50965652', found: '2038465934478'