QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#748642 | #9619. 乘积,欧拉函数,求和 | zenglx | WA | 1ms | 5832kb | C++20 | 1.1kb | 2024-11-14 20:57:00 | 2024-11-14 20:57:00 |
Judging History
answer
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
// #define i128 __int128
using namespace std;
typedef long long ll;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int N = 1e5 + 5;
const int mod = 998244353;
int n;
int a[N];
int ans;
bool is[N];
int inv[N];
int dp[N];
vector<int> p[N];
void init(){
for(int i=1;i<=3000;i++)
is[i]=true;
for(int i=2;i<=3000;i++){
if(is[i]){
p[i].push_back(i);
for(int j=2;i*j<=3000;j++){
is[i*j]=false;
p[i*j].push_back(i);
}
}
}
inv[1]=1;
for(int i=2;i<=3000;i++){
inv[i]=(mod-(mod/i*inv[mod%i]%mod))%mod;
}
return;
}
void solve(){
cin>>n;
init();
for(int i=1;i<=n;i++){
cin>>a[i];
}
dp[0]=1;
for(int i=1;i<=n;i++){
int sum=dp[i-1]*a[i]%mod;
for(auto num:p[a[i]]){
sum*=(num-1)*inv[num]%mod;
sum%=mod;
}
dp[i]=(dp[i-1]+sum)%mod;
}
cout<<dp[n]<<endl;
return;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
// cout<<setiosflags(ios::fixed)<<setprecision(1);
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: 1ms
memory: 5832kb
input:
5 1 6 8 6 2
output:
180
result:
wrong answer 1st lines differ - expected: '892', found: '180'