Created
December 9, 2014 19:57
-
-
Save ik11235/c84a777a45f9b54ce740 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NumberGameAgain { | |
public: | |
long long solve(int k, vector<long long> table) { | |
const long long int MAX=((long long)2<<(k-1)); | |
sort(table.begin(), table.end()); | |
long long int cnt=MAX-2; | |
for(int i=0;i<table.size();i++) | |
{ | |
long long int ii=table[i]/2; | |
int tree=1; | |
bool flag=false; | |
while(ii>1) | |
{ | |
if(binary_search(table.begin(), table.end(), ii)) | |
{ | |
flag=true; | |
break; | |
} | |
ii=ii/2; | |
tree++; | |
} | |
if(flag) | |
continue; | |
cnt-=((long long)1<<(k-tree))-1; | |
} | |
return cnt; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment