Submission #19254

# Submission time Handle Problem Language Result Execution time Memory
19254 2016-02-23T02:27:58 Z kaTkaHr 동전 (kriii4_E) C++14
100 / 100
253 ms 2100 KB
#include <stdio.h>
#include<vector>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;

const int MX = 255, MM = 1000000007;

ll rv(ll A){
	ll R = 1, B = MM-2;
	while(B){
		if( B&1 ) R = R * A % MM;
		A = A * A % MM; B /= 2;
	}
	return R;
}

struct frac{
	ll A, B;
	frac(ll A):A(A), B(1){}
	frac(ll a, ll b){
		A = (a%MM+MM) % MM;
		B = (b%MM+MM) % MM;
	}
	frac(){A = 0, B = 1;}
	frac operator+ (const frac &l)const{
		return frac((A * l.B + B * l.A) % MM, B * l.B % MM);
	}
	frac operator*(const frac &l)const{
		return frac(A*l.A % MM, B*l.B % MM);
	}
	frac operator/(const frac &l)const{
		return frac(A*l.B % MM, B*l.A % MM);
	}
	frac operator- (const frac &l)const{
		return frac((A*l.B - B*l.A%MM + MM) % MM, B*l.B % MM);
	}
	ll v(){ return A * rv(B) % MM; }
};

frac T[MX][MX];

int main()
{
	int N;
	scanf("%d", &N);
	T[0][0] = 1;
	for(int i = 1; i <= N; i++){
		T[i][i] = 1;
		for(int j = 0; j <= N; j++){
			for(int k = 1; k <= i; k++){
				T[i][j] = T[i][j] + T[i-k][j^(k-1)];
			}
		}
	}
	printf("%lld\n", T[N][0].v());
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2100 KB Output is correct
2 Correct 0 ms 2100 KB Output is correct
3 Correct 0 ms 2100 KB Output is correct
4 Correct 0 ms 2100 KB Output is correct
5 Correct 0 ms 2100 KB Output is correct
6 Correct 0 ms 2100 KB Output is correct
7 Correct 0 ms 2100 KB Output is correct
8 Correct 0 ms 2100 KB Output is correct
9 Correct 0 ms 2100 KB Output is correct
10 Correct 0 ms 2100 KB Output is correct
11 Correct 0 ms 2100 KB Output is correct
12 Correct 0 ms 2100 KB Output is correct
13 Correct 0 ms 2100 KB Output is correct
14 Correct 0 ms 2100 KB Output is correct
15 Correct 0 ms 2100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 2100 KB Output is correct
2 Correct 71 ms 2100 KB Output is correct
3 Correct 1 ms 2100 KB Output is correct
4 Correct 10 ms 2100 KB Output is correct
5 Correct 2 ms 2100 KB Output is correct
6 Correct 14 ms 2100 KB Output is correct
7 Correct 137 ms 2100 KB Output is correct
8 Correct 197 ms 2100 KB Output is correct
9 Correct 29 ms 2100 KB Output is correct
10 Correct 179 ms 2100 KB Output is correct
11 Correct 11 ms 2100 KB Output is correct
12 Correct 11 ms 2100 KB Output is correct
13 Correct 166 ms 2100 KB Output is correct
14 Correct 86 ms 2100 KB Output is correct
15 Correct 28 ms 2100 KB Output is correct
16 Correct 3 ms 2100 KB Output is correct
17 Correct 241 ms 2100 KB Output is correct
18 Correct 2 ms 2100 KB Output is correct
19 Correct 69 ms 2100 KB Output is correct
20 Correct 5 ms 2100 KB Output is correct
21 Correct 118 ms 2100 KB Output is correct
22 Correct 79 ms 2100 KB Output is correct
23 Correct 42 ms 2100 KB Output is correct
24 Correct 20 ms 2100 KB Output is correct
25 Correct 8 ms 2100 KB Output is correct
26 Correct 2 ms 2100 KB Output is correct
27 Correct 167 ms 2100 KB Output is correct
28 Correct 0 ms 2100 KB Output is correct
29 Correct 161 ms 2100 KB Output is correct
30 Correct 253 ms 2100 KB Output is correct