QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#740346 | #9619. 乘积,欧拉函数,求和 | nb_jzy | WA | 6ms | 4612kb | C++20 | 1.5kb | 2024-11-13 09:14:35 | 2024-11-13 09:14:41 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=3005,maxs=17,mod=998244353;
int a[maxn],cnt=-1,n,len,f[1<<maxs],ny[maxn],s[maxn],prime[22],pro[1<<maxs];
vector<int> g[maxn];
int poww(int x,int y){
int res=1;
while(y>0){
if(y&1){
res=res*x%mod;
}
x=x*x%mod;
y>>=1;
}
return res;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
for(int i=1;i<=3000;i++){
ny[i]=poww(i,mod-2);
}
for(int i=2;i<=55;i++){
bool f=1;
for(int j=2;j*j<=i;j++){
if(i%j==0){
f=0;
break;
}
}
if(f){
cnt++;
prime[cnt]=i;
}
}
cnt++;
cin>>n;
for(int i=0;i<cnt;i++){
cout<<prime[i]<<" ";
}
cout<<'\n';
int len=(1<<cnt)-1;
for(int i=0;i<=len;i++){
pro[i]=1;
for(int j=0;j<cnt;j++){
if((i>>j)&1){
pro[i]=(prime[j]-1)*pro[i]%mod*ny[prime[j]]%mod;
}
}
}
int cntt=0;
for(int i=1;i<=n;i++){
cin>>a[i];
int xx=a[i];
for(int j=0;j<cnt;j++){
while(xx%prime[j]==0){
s[i]|=(1<<j);
xx/=prime[j];
}
}
g[xx].push_back(i);
}
int ans=1;
for(int i=1;i<=3000;i++){
sort(g[i].begin(),g[i].end());
if(g[i].empty()){
continue;
}
for(int j=0;j<=len;j++){
f[j]=0;
}
for(auto v:g[i]){
for(int j=len;j>0;j--){
f[j|s[v]]=(f[j]*a[v]+f[j|s[v]])%mod;
}
f[s[v]]=(f[0]+1)*a[v]%mod;
}
int res=0;
for(int j=0;j<=len;j++){
res=(f[j]*pro[j]+res)%mod;
}
if(i>1){
res=res*ny[i]%mod*(i-1)%mod;
}
ans=ans*(res+1)%mod;
}
cout<<ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 6ms
memory: 4612kb
input:
5 1 6 8 6 2
output:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 16
result:
wrong answer 1st lines differ - expected: '892', found: '2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 '