답안 #9134

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
9134 2014-09-27T13:09:52 Z imsifile Actual visible points (kriii2_AC) C++
4 / 4
220 ms 7336 KB
#include<stdio.h>
#define mod 1000000007

typedef long long lld;

int n, m, mx, ba[200000];
lld fac[300000], soin[200000], real[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, j, a;
	scanf("%d%d", &n, &m);
	fac[0]=1;
	for(i=1; i<300000; i++)fac[i]=fac[i-1]*i%mod;
	for(i=0; i<m; i++){
		scanf("%d", &a);
		if(mx<a)mx=a;
		ba[a]=1;
	}
	for(i=1; i<=mx; i++){
		if(ba[i])continue;
		for(a=i*2; a<=mx; a+=i){
			if(ba[a])break;
		}
		if(a<=mx)ba[i]=1;
	}
	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++){
		if(!ba[i])continue;
		for(a=1; a*a<=i; a++){
			if(i%a==0){
				real[i/a]+=soin[a];
				if(a*a<i)real[a]+=soin[i/a];
			}
		}
	}
	for(i=1; i<=mx; i++){
		dap+=real[i]*comb(i+n-2, n-1);
		dap=(dap+mod)%mod;
	}
	printf("%lld", dap);
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 7336 KB Output is correct
2 Correct 60 ms 7336 KB Output is correct
3 Correct 60 ms 7336 KB Output is correct
4 Correct 64 ms 7336 KB Output is correct
5 Correct 64 ms 7336 KB Output is correct
6 Correct 56 ms 7336 KB Output is correct
7 Correct 64 ms 7336 KB Output is correct
8 Correct 64 ms 7336 KB Output is correct
9 Correct 64 ms 7336 KB Output is correct
10 Correct 60 ms 7336 KB Output is correct
11 Correct 64 ms 7336 KB Output is correct
12 Correct 68 ms 7336 KB Output is correct
13 Correct 64 ms 7336 KB Output is correct
14 Correct 68 ms 7336 KB Output is correct
15 Correct 68 ms 7336 KB Output is correct
16 Correct 68 ms 7336 KB Output is correct
17 Correct 60 ms 7336 KB Output is correct
18 Correct 60 ms 7336 KB Output is correct
19 Correct 68 ms 7336 KB Output is correct
20 Correct 68 ms 7336 KB Output is correct
21 Correct 68 ms 7336 KB Output is correct
22 Correct 76 ms 7336 KB Output is correct
23 Correct 60 ms 7336 KB Output is correct
24 Correct 80 ms 7336 KB Output is correct
25 Correct 60 ms 7336 KB Output is correct
26 Correct 100 ms 7336 KB Output is correct
27 Correct 68 ms 7336 KB Output is correct
28 Correct 100 ms 7336 KB Output is correct
29 Correct 88 ms 7336 KB Output is correct
30 Correct 68 ms 7336 KB Output is correct
31 Correct 220 ms 7336 KB Output is correct
32 Correct 192 ms 7336 KB Output is correct
33 Correct 192 ms 7336 KB Output is correct
34 Correct 168 ms 7336 KB Output is correct
35 Correct 168 ms 7336 KB Output is correct
36 Correct 192 ms 7336 KB Output is correct
37 Correct 196 ms 7336 KB Output is correct
38 Correct 168 ms 7336 KB Output is correct
39 Correct 172 ms 7336 KB Output is correct
40 Correct 156 ms 7336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 7336 KB Output is correct
2 Correct 60 ms 7336 KB Output is correct
3 Correct 60 ms 7336 KB Output is correct
4 Correct 64 ms 7336 KB Output is correct
5 Correct 64 ms 7336 KB Output is correct
6 Correct 60 ms 7336 KB Output is correct
7 Correct 64 ms 7336 KB Output is correct
8 Correct 60 ms 7336 KB Output is correct
9 Correct 60 ms 7336 KB Output is correct
10 Correct 60 ms 7336 KB Output is correct
11 Correct 64 ms 7336 KB Output is correct
12 Correct 64 ms 7336 KB Output is correct
13 Correct 64 ms 7336 KB Output is correct
14 Correct 68 ms 7336 KB Output is correct
15 Correct 68 ms 7336 KB Output is correct
16 Correct 64 ms 7336 KB Output is correct
17 Correct 68 ms 7336 KB Output is correct
18 Correct 64 ms 7336 KB Output is correct
19 Correct 64 ms 7336 KB Output is correct
20 Correct 64 ms 7336 KB Output is correct
21 Correct 68 ms 7336 KB Output is correct
22 Correct 80 ms 7336 KB Output is correct
23 Correct 68 ms 7336 KB Output is correct
24 Correct 92 ms 7336 KB Output is correct
25 Correct 64 ms 7336 KB Output is correct
26 Correct 104 ms 7336 KB Output is correct
27 Correct 68 ms 7336 KB Output is correct
28 Correct 96 ms 7336 KB Output is correct
29 Correct 84 ms 7336 KB Output is correct
30 Correct 68 ms 7336 KB Output is correct
31 Correct 208 ms 7336 KB Output is correct
32 Correct 180 ms 7336 KB Output is correct
33 Correct 188 ms 7336 KB Output is correct
34 Correct 168 ms 7336 KB Output is correct
35 Correct 180 ms 7336 KB Output is correct
36 Correct 192 ms 7336 KB Output is correct
37 Correct 196 ms 7336 KB Output is correct
38 Correct 172 ms 7336 KB Output is correct
39 Correct 176 ms 7336 KB Output is correct
40 Correct 164 ms 7336 KB Output is correct