We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3293e0c commit c7601acCopy full SHA for c7601ac
dp_&_bit_masking/ghost_type.cpp
@@ -0,0 +1,34 @@
1
+#include<bits/stdc++.h>
2
+using namespace std;
3
+
4
5
+long long int dp[1 << 20];
6
+int can[20];
7
+int main(){
8
+ int n;
9
+ cin >> n;
10
+ dp[0] = 1;
11
+ for (int i = 0; i < n; i++){
12
+ for (int j = 0; j < n; j++){
13
+ if (i == j)continue;
14
+ if (((i + 1) & (j + 1)) == j + 1){
15
+ can[i] |= (1 << j);
16
+ }
17
18
19
+ for (int i = 0; i < (1 << n); i++){
20
21
22
+ if ((i >> j) & 1){
23
24
25
+ else{
26
+ if ((i&can[j]) == can[j]){
27
+ dp[i | (1 << j)] += dp[i];
28
29
30
31
32
+ cout << dp[(1 << n) - 1]<< endl;
33
+ return 0;
34
+}
0 commit comments