标签:c++ def div pre include mod turn print max
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=3e5+100; const int mod=998244353; ll fpow (int x,int y) { ll ans=1; while (y) { if (y&1) ans=ans*x%mod; x=1ll*x*x%mod; y>>=1; } return ans; } ll a[maxn]; int n; ll wjm; int main () { scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%lld",&a[i]); sort(a+1,a+1+n); for (int i=1;i<=n;i++) a[i]+=a[i-1]; wjm=fpow(n,mod-2); for (int i=1;i<=n;i++) { ll ans=0; for (int j=n-i,k=1;j>0;j-=i,k++) { ans+=1ll*k*(a[j]-a[max(0,j-i)])%mod; ans%=mod; } printf("%lld ",ans*wjm%mod); } }
标签:c++ def div pre include mod turn print max
原文地址:https://www.cnblogs.com/zhanglichen/p/13337208.html