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 <set>
#include <algorithm>
using namespace std;
int n,m;
const int mod = 1000000007;
long long fact[203000];
long long ifact[203000];
long long invs[203000];
long long counts[100003];
int main(){
invs[1] = 1;
for(int i = 2; i <= 200010; i++) invs[i] = (invs[mod%i] * (mod-mod/i)) % mod;
fact[0] = 1;
for(int i = 1; i <= 200010; i++) fact[i] = i * fact[i-1] % mod;
ifact[0] = 1;
for(int i = 1; i <= 200010; i++) ifact[i] = (invs[i] * ifact[i-1]) % mod;
scanf("%d%d",&n,&m);
set<int> xs;
for(int i = 0; i < m; i++) {
int x;
scanf("%d",&x);
xs.insert(x);
}
long long ans = 0;
for(int i = 1; i <= 100000; i++) {
counts[i] += fact[i+(n-2)] * ifact[n-1] % mod * ifact[i-1] % mod;
counts[i] %= mod;
if (xs.count(i) == 0) continue;
ans += counts[i];
for(int j = i*2; j <= 100000; j += i) {
counts[j] -= counts[i];
}
}
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... |