QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#738996 | #9619. 乘积,欧拉函数,求和 | ucup-team4975# | WA | 2ms | 3648kb | C++14 | 1.6kb | 2024-11-12 20:29:36 | 2024-11-12 20:29:44 |
Judging History
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;
}
详细
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'