QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#748642#9619. 乘积,欧拉函数,求和zenglxWA 1ms5832kbC++201.1kb2024-11-14 20:57:002024-11-14 20:57:00

Judging History

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

  • [2024-11-14 20:57:00]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5832kb
  • [2024-11-14 20:57:00]
  • 提交

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;
}

详细

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'