General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
120295119 Practice:
IAKCodeForces
653G - 16 GNU C++11 Accepted 327 ms 27016 KB 2021-06-22 16:29:10 2021-06-22 16:29:10
→ Source
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=1e9+7,N=300005;
int n,cnt[N][20],fac[N],inv[N],x,pre[N];
int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(ll)x*x%M)
		if (y&1)ans=(ll)ans*x%M;
	return ans;
}
int C(int x,int y){
	if (x<y)return 0;
	return (ll)fac[x]*inv[y]%M*inv[x-y]%M;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&x);
		for (int j=2;j*j<=x;j++)
			if (x%j==0){
				int v=0;
				while (x%j==0)x/=j,v++;
				cnt[j][v]++;
			}
		if (x!=1)cnt[x][1]++;
	}
	fac[0]=inv[0]=1;
	int ans=0;
	for (int i=1;i<=n;i++)fac[i]=(ll)fac[i-1]*i%M,inv[i]=ksm(fac[i],M-2);
	pre[0]=C(n-1,0);
	for (int i=1;i<n;i++)pre[i]=(pre[i-1]+C(n-1,i))%M;
	for (int i=1;i<=300000;i++){
		int tot=n;
		for (int j=1;j<19;j++)tot-=cnt[i][j];
		for (int j=1;j<19;j++){
			int l=tot+1,r=tot+cnt[i][j];
			for (int k=l;k<=r;k++)ans=(ans+((ll)(k==1?0:pre[k-2])-pre[n-1]+pre[k-1]+M)*j)%M;
			tot+=cnt[i][j];
		}
	}
	printf("%d\n",ans);
}
//I am a bot for remotejudge
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details