This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;
int n,m;
const int mod = 1000000007;
long long fact[2030000];
long long ifact[2030000];
long long invs[2030000];
long long counts[1000030];
int main(){
invs[1] = 1;
for(int i = 2; i <= 400010; i++) invs[i] = (invs[mod%i] * (mod-mod/i)) % mod;
fact[0] = 1;
for(int i = 1; i <= 400010; i++) fact[i] = i * fact[i-1] % mod;
ifact[0] = 1;
for(int i = 1; i <= 400010; i++) ifact[i] = (invs[i] * ifact[i-1]) % mod;
scanf("%d%d",&n,&m);
for(int i = 1; i <= 200000; i++) {
counts[i] += fact[i+(n-2)] * ifact[n-1] % mod * ifact[i-1] % mod;
counts[i] %= mod;
for(int j = i*2; j <= 200000; j += i) {
counts[j] -= counts[i];
}
}
set<int> tmp;
long long ans = 0;
for(int i = 0; i < m; i++) {
int x;
scanf("%d",&x);
ans += counts[x];
if (tmp.insert(x).second == false) {
for(;;);
}
}
ans %= mod;
ans += mod;
ans %= mod;
printf("%lld\n", ans);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |