QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#738638 | #9619. 乘积,欧拉函数,求和 | rotcar07 | WA | 203ms | 5292kb | C++23 | 1.3kb | 2024-11-12 19:36:26 | 2024-11-12 19:36:26 |
Judging History
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,53},ipr[16]={499122177, 665496236, 399297742, 142606337, 725995894, 537516191, 58720257, 893166001, 781234712, 516333287, 869438631, 755428160, 900854661, 487514685, 807091180, 169513193};
constexpr int N=1<<16;
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<16;i++)if(x%pr[i]==0){
while(x%pr[i]==0) x/=pr[i];
y|=1<<i;
}
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: 2ms
memory: 5132kb
input:
5 1 6 8 6 2
output:
892
result:
ok single line: '892'
Test #2:
score: 0
Accepted
time: 0ms
memory: 5192kb
input:
5 3 8 3 7 8
output:
3157
result:
ok single line: '3157'
Test #3:
score: -100
Wrong Answer
time: 203ms
memory: 5292kb
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:
4067896704127
result:
wrong answer 1st lines differ - expected: '50965652', found: '4067896704127'