#pragma warning(disable:4996)
#include<stdio.h>
#include<algorithm>
using namespace std;
int n, m, w[101000];
long long Mod = 1000000007, F[201000], G[201000], Res;
bool chk[101000];
long long Inv(long long a){
long long cnt = Mod - 2, r = 1;
while (cnt){
if (cnt % 2){
r = r*a%Mod;
}
cnt /= 2;
a = a*a%Mod;
}
return r;
}
long long Gap(int a){
if (a == 0)return 0;
return F[a + n - 1] * Inv(F[n]) % Mod * Inv(F[a - 1]) % Mod;
}
void Do(int a){
G[a] = (G[a] + Gap(a) - Gap(a-1) + Mod) % Mod;
int i, ck = chk[a];
for (i = a * 2; i <= 100000; i += a){
G[i] = (G[i] + Mod - G[a]) % Mod;
if (chk[i])ck = true;
}
if (ck)Res = (Res + G[a]) % Mod;
}
int main()
{
int i;
scanf("%d%d", &n, &m);
for (i = 1; i <= m; i++){
scanf("%d", &w[i]);
chk[w[i]] = true;
}
F[0] = 1;
for (i = 1; i <= 200010; i++){
F[i] = F[i - 1] * i%Mod;
}
for (i = 1; i <= 100000; i++){
Do(i);
}
printf("%lld\n", Res);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
352 ms |
4720 KB |
Output is correct |
2 |
Correct |
344 ms |
4720 KB |
Output is correct |
3 |
Correct |
352 ms |
4720 KB |
Output is correct |
4 |
Correct |
356 ms |
4720 KB |
Output is correct |
5 |
Correct |
348 ms |
4720 KB |
Output is correct |
6 |
Correct |
352 ms |
4720 KB |
Output is correct |
7 |
Correct |
352 ms |
4720 KB |
Output is correct |
8 |
Correct |
348 ms |
4720 KB |
Output is correct |
9 |
Correct |
352 ms |
4720 KB |
Output is correct |
10 |
Correct |
352 ms |
4720 KB |
Output is correct |
11 |
Correct |
352 ms |
4720 KB |
Output is correct |
12 |
Correct |
352 ms |
4720 KB |
Output is correct |
13 |
Correct |
352 ms |
4720 KB |
Output is correct |
14 |
Correct |
352 ms |
4720 KB |
Output is correct |
15 |
Correct |
352 ms |
4720 KB |
Output is correct |
16 |
Correct |
352 ms |
4720 KB |
Output is correct |
17 |
Correct |
352 ms |
4720 KB |
Output is correct |
18 |
Correct |
348 ms |
4720 KB |
Output is correct |
19 |
Correct |
352 ms |
4720 KB |
Output is correct |
20 |
Correct |
352 ms |
4720 KB |
Output is correct |
21 |
Correct |
348 ms |
4720 KB |
Output is correct |
22 |
Correct |
352 ms |
4720 KB |
Output is correct |
23 |
Correct |
348 ms |
4720 KB |
Output is correct |
24 |
Correct |
356 ms |
4720 KB |
Output is correct |
25 |
Correct |
348 ms |
4720 KB |
Output is correct |
26 |
Correct |
352 ms |
4720 KB |
Output is correct |
27 |
Correct |
352 ms |
4720 KB |
Output is correct |
28 |
Correct |
356 ms |
4720 KB |
Output is correct |
29 |
Correct |
348 ms |
4720 KB |
Output is correct |
30 |
Correct |
352 ms |
4720 KB |
Output is correct |
31 |
Correct |
368 ms |
4720 KB |
Output is correct |
32 |
Correct |
368 ms |
4720 KB |
Output is correct |
33 |
Correct |
364 ms |
4720 KB |
Output is correct |
34 |
Correct |
356 ms |
4720 KB |
Output is correct |
35 |
Correct |
360 ms |
4720 KB |
Output is correct |
36 |
Correct |
360 ms |
4720 KB |
Output is correct |
37 |
Correct |
364 ms |
4720 KB |
Output is correct |
38 |
Correct |
356 ms |
4720 KB |
Output is correct |
39 |
Correct |
360 ms |
4720 KB |
Output is correct |
40 |
Correct |
364 ms |
4720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
352 ms |
4720 KB |
Output is correct |
2 |
Correct |
352 ms |
4720 KB |
Output is correct |
3 |
Correct |
352 ms |
4720 KB |
Output is correct |
4 |
Correct |
356 ms |
4720 KB |
Output is correct |
5 |
Correct |
352 ms |
4720 KB |
Output is correct |
6 |
Correct |
352 ms |
4720 KB |
Output is correct |
7 |
Correct |
352 ms |
4720 KB |
Output is correct |
8 |
Correct |
352 ms |
4720 KB |
Output is correct |
9 |
Correct |
352 ms |
4720 KB |
Output is correct |
10 |
Correct |
356 ms |
4720 KB |
Output is correct |
11 |
Correct |
356 ms |
4720 KB |
Output is correct |
12 |
Correct |
356 ms |
4720 KB |
Output is correct |
13 |
Correct |
356 ms |
4720 KB |
Output is correct |
14 |
Correct |
356 ms |
4720 KB |
Output is correct |
15 |
Correct |
356 ms |
4720 KB |
Output is correct |
16 |
Correct |
356 ms |
4720 KB |
Output is correct |
17 |
Correct |
352 ms |
4720 KB |
Output is correct |
18 |
Correct |
356 ms |
4720 KB |
Output is correct |
19 |
Correct |
356 ms |
4720 KB |
Output is correct |
20 |
Correct |
356 ms |
4720 KB |
Output is correct |
21 |
Correct |
356 ms |
4720 KB |
Output is correct |
22 |
Correct |
356 ms |
4720 KB |
Output is correct |
23 |
Correct |
356 ms |
4720 KB |
Output is correct |
24 |
Correct |
360 ms |
4720 KB |
Output is correct |
25 |
Correct |
356 ms |
4720 KB |
Output is correct |
26 |
Correct |
360 ms |
4720 KB |
Output is correct |
27 |
Correct |
352 ms |
4720 KB |
Output is correct |
28 |
Correct |
356 ms |
4720 KB |
Output is correct |
29 |
Correct |
352 ms |
4720 KB |
Output is correct |
30 |
Correct |
356 ms |
4720 KB |
Output is correct |
31 |
Correct |
364 ms |
4720 KB |
Output is correct |
32 |
Correct |
360 ms |
4720 KB |
Output is correct |
33 |
Correct |
364 ms |
4720 KB |
Output is correct |
34 |
Correct |
356 ms |
4720 KB |
Output is correct |
35 |
Correct |
364 ms |
4720 KB |
Output is correct |
36 |
Correct |
360 ms |
4720 KB |
Output is correct |
37 |
Correct |
372 ms |
4720 KB |
Output is correct |
38 |
Correct |
364 ms |
4720 KB |
Output is correct |
39 |
Correct |
360 ms |
4720 KB |
Output is correct |
40 |
Correct |
368 ms |
4720 KB |
Output is correct |