답안 #9137

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
9137 2014-09-27T14:09:20 Z ainta Actual visible points (kriii2_AC) C++
4 / 4
208 ms 6292 KB
#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, invF[201000];
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] * invF[n] % Mod * invF[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;
	}
	invF[0] = F[0] = 1;
	for (i = 1; i <= 200010; i++){
		F[i] = F[i - 1] * i%Mod;
		invF[i] = Inv(F[i]);
	}
	for (i = 1; i <= 100000; i++){
		Do(i);
	}
	printf("%lld\n", Res);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 196 ms 6292 KB Output is correct
2 Correct 188 ms 6292 KB Output is correct
3 Correct 196 ms 6292 KB Output is correct
4 Correct 196 ms 6292 KB Output is correct
5 Correct 192 ms 6292 KB Output is correct
6 Correct 196 ms 6292 KB Output is correct
7 Correct 196 ms 6292 KB Output is correct
8 Correct 196 ms 6292 KB Output is correct
9 Correct 192 ms 6292 KB Output is correct
10 Correct 192 ms 6292 KB Output is correct
11 Correct 196 ms 6292 KB Output is correct
12 Correct 196 ms 6292 KB Output is correct
13 Correct 192 ms 6292 KB Output is correct
14 Correct 196 ms 6292 KB Output is correct
15 Correct 192 ms 6292 KB Output is correct
16 Correct 192 ms 6292 KB Output is correct
17 Correct 196 ms 6292 KB Output is correct
18 Correct 196 ms 6292 KB Output is correct
19 Correct 188 ms 6292 KB Output is correct
20 Correct 196 ms 6292 KB Output is correct
21 Correct 196 ms 6292 KB Output is correct
22 Correct 192 ms 6292 KB Output is correct
23 Correct 196 ms 6292 KB Output is correct
24 Correct 200 ms 6292 KB Output is correct
25 Correct 196 ms 6292 KB Output is correct
26 Correct 196 ms 6292 KB Output is correct
27 Correct 196 ms 6292 KB Output is correct
28 Correct 196 ms 6292 KB Output is correct
29 Correct 188 ms 6292 KB Output is correct
30 Correct 188 ms 6292 KB Output is correct
31 Correct 204 ms 6292 KB Output is correct
32 Correct 204 ms 6292 KB Output is correct
33 Correct 200 ms 6292 KB Output is correct
34 Correct 200 ms 6292 KB Output is correct
35 Correct 196 ms 6292 KB Output is correct
36 Correct 208 ms 6292 KB Output is correct
37 Correct 204 ms 6292 KB Output is correct
38 Correct 204 ms 6292 KB Output is correct
39 Correct 204 ms 6292 KB Output is correct
40 Correct 204 ms 6292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 192 ms 6292 KB Output is correct
2 Correct 188 ms 6292 KB Output is correct
3 Correct 192 ms 6292 KB Output is correct
4 Correct 196 ms 6292 KB Output is correct
5 Correct 188 ms 6292 KB Output is correct
6 Correct 192 ms 6292 KB Output is correct
7 Correct 192 ms 6292 KB Output is correct
8 Correct 196 ms 6292 KB Output is correct
9 Correct 196 ms 6292 KB Output is correct
10 Correct 196 ms 6292 KB Output is correct
11 Correct 196 ms 6292 KB Output is correct
12 Correct 196 ms 6292 KB Output is correct
13 Correct 192 ms 6292 KB Output is correct
14 Correct 196 ms 6292 KB Output is correct
15 Correct 196 ms 6292 KB Output is correct
16 Correct 192 ms 6292 KB Output is correct
17 Correct 196 ms 6292 KB Output is correct
18 Correct 200 ms 6292 KB Output is correct
19 Correct 196 ms 6292 KB Output is correct
20 Correct 196 ms 6292 KB Output is correct
21 Correct 196 ms 6292 KB Output is correct
22 Correct 196 ms 6292 KB Output is correct
23 Correct 196 ms 6292 KB Output is correct
24 Correct 196 ms 6292 KB Output is correct
25 Correct 192 ms 6292 KB Output is correct
26 Correct 192 ms 6292 KB Output is correct
27 Correct 192 ms 6292 KB Output is correct
28 Correct 192 ms 6292 KB Output is correct
29 Correct 188 ms 6292 KB Output is correct
30 Correct 196 ms 6292 KB Output is correct
31 Correct 208 ms 6292 KB Output is correct
32 Correct 192 ms 6292 KB Output is correct
33 Correct 208 ms 6292 KB Output is correct
34 Correct 200 ms 6292 KB Output is correct
35 Correct 204 ms 6292 KB Output is correct
36 Correct 200 ms 6292 KB Output is correct
37 Correct 200 ms 6292 KB Output is correct
38 Correct 208 ms 6292 KB Output is correct
39 Correct 208 ms 6292 KB Output is correct
40 Correct 200 ms 6292 KB Output is correct