You are not logged in. Please login at www.codechef.com to post your questions!

×

The Ghost Type

https://www.hackerearth.com/practice/algorithms/dynamic-programming/bit-masking/practice-problems/algorithm/the-ghost-type/description/

Here is the link of the above problem i have been trying. Just want to know where i am going wrong with my this code?

include<bits stdc++.h="">

using namespace std; int n; int getcount(int mask){ if(mask== (1<<(n)-1)) return 1; int count=0; for(int i=0;i<n;i++){ if(!mask&(1<<i)){ for(int j=1; j<=n; j++){ if(!mask&(1<<(j-1)) && (i+1)&(j)==(i+1)) if(getcount(mask|(1<<i))) count++ ; } } } return count; } int main(){

cin>>n;

cout<<getcount(0)<<endl;

return 0;

} please help me with the above one.

asked 02 Jan, 20:39

riju321's gravatar image

2★riju321
1
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×2,169

question asked: 02 Jan, 20:39

question was seen: 49 times

last updated: 02 Jan, 20:39