Submission #19806

# Submission time Handle Problem Language Result Execution time Memory
19806 2016-02-25T05:47:29 Z myungwoo 동전 (kriii4_E) C++14
100 / 100
33 ms 17900 KB
#include<stdio.h>
#include<memory.h>
#define mod 1000000007
#define inv(a) exp(a,mod-2)

typedef long long lld;

lld exp(lld a, lld b){
	if(b==0)return 1;
	lld k=exp(a, b/2);
	k=(k*k)%mod;
	if(b%2)k=(k*a)%mod;
	return k;
}

lld fac[1001001], rfac[1001001];

void init(){
	lld i;
	fac[0]=rfac[0]=1;
	for(i=1; i<=1000000; i++){
		fac[i]=(fac[i-1]*i)%mod;
		rfac[i]=inv(fac[i]);
	}
}

lld comb(lld a, lld b){
	return fac[a]*rfac[b]%mod*rfac[a-b]%mod;
}

lld n, grd[251], dy[251][600];

int main(){
	lld i, j, k;
//	init();
	scanf("%d", &n);
	for(i=1; i<=n; i++)grd[i]=i;

	dy[0][0]=1;
	for(i=1; i<=n; i++){
		for(j=0; j<512; j++){
			if(grd[i]==j)dy[i][j]++;
			for(k=0; k<i; k++)dy[i][j]+=dy[k][j^grd[i-k-1]];
			dy[i][j]%=mod;
		}
	}

	printf("%lld", dy[n][0]);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 17900 KB Output is correct
2 Correct 0 ms 17900 KB Output is correct
3 Correct 0 ms 17900 KB Output is correct
4 Correct 0 ms 17900 KB Output is correct
5 Correct 0 ms 17900 KB Output is correct
6 Correct 0 ms 17900 KB Output is correct
7 Correct 0 ms 17900 KB Output is correct
8 Correct 0 ms 17900 KB Output is correct
9 Correct 0 ms 17900 KB Output is correct
10 Correct 0 ms 17900 KB Output is correct
11 Correct 0 ms 17900 KB Output is correct
12 Correct 0 ms 17900 KB Output is correct
13 Correct 0 ms 17900 KB Output is correct
14 Correct 0 ms 17900 KB Output is correct
15 Correct 0 ms 17900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 17900 KB Output is correct
2 Correct 15 ms 17900 KB Output is correct
3 Correct 0 ms 17900 KB Output is correct
4 Correct 4 ms 17900 KB Output is correct
5 Correct 0 ms 17900 KB Output is correct
6 Correct 6 ms 17900 KB Output is correct
7 Correct 23 ms 17900 KB Output is correct
8 Correct 28 ms 17900 KB Output is correct
9 Correct 9 ms 17900 KB Output is correct
10 Correct 23 ms 17900 KB Output is correct
11 Correct 2 ms 17900 KB Output is correct
12 Correct 4 ms 17900 KB Output is correct
13 Correct 21 ms 17900 KB Output is correct
14 Correct 17 ms 17900 KB Output is correct
15 Correct 9 ms 17900 KB Output is correct
16 Correct 2 ms 17900 KB Output is correct
17 Correct 31 ms 17900 KB Output is correct
18 Correct 0 ms 17900 KB Output is correct
19 Correct 15 ms 17900 KB Output is correct
20 Correct 3 ms 17900 KB Output is correct
21 Correct 20 ms 17900 KB Output is correct
22 Correct 12 ms 17900 KB Output is correct
23 Correct 7 ms 17900 KB Output is correct
24 Correct 3 ms 17900 KB Output is correct
25 Correct 4 ms 17900 KB Output is correct
26 Correct 0 ms 17900 KB Output is correct
27 Correct 25 ms 17900 KB Output is correct
28 Correct 0 ms 17900 KB Output is correct
29 Correct 25 ms 17900 KB Output is correct
30 Correct 33 ms 17900 KB Output is correct