Submission #9099

#TimeUsernameProblemLanguageResultExecution timeMemory
9099imsifileActual visible points (kriii2_AC)C++98
0 / 4
60 ms4992 KiB
#include<stdio.h> #define mod 1000000007 typedef long long lld; int n, m, mx; lld fac[300000], soin[200000], dap; lld exp(lld x, lld y){ if(y==0)return 1; lld im=exp(x,y/2); im=(im*im)%mod; if(y%2)im=(im*x)%mod; return im; } lld comb(lld a, lld b){ lld im=fac[a-b]*fac[b]%mod; return fac[a]*exp(im,mod-2)%mod; } int main(){ int i, a; scanf("%d%d", &n, &m); for(i=0; i<m; i++){ scanf("%d", &a); if(mx<a)mx=a; } fac[0]=1; for(i=1; i<300000; i++)fac[i]=fac[i-1]*i%mod; soin[1]=1; for(i=2; i<=mx; i++){ for(a=2; a*a<=i; a++){ if(i%a==0)break; } if(a*a>i)soin[i]=-1; else if(i%(a*a)==0)soin[i]=0; else soin[i]=soin[i/a]*soin[a]; } for(i=1; i<=mx; i++){ dap+=soin[i]*comb(mx/i+n-1, n); dap=(dap+mod)%mod; } printf("%lld", dap); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...