-
-
Save wang-nima/92780af364355374e082 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
struct TreeNode { | |
bool color; | |
vector<TreeNode*> next; | |
TreeNode (bool c) : color(c), next(4, nullptr) {} | |
}; | |
double getPercentage(TreeNode *root) { | |
if (next[0] == nullptr && next[1] == nullptr && next[2] == nullptr && next[3] == nullptr) { | |
return 1; | |
} | |
double sum = 0; | |
for (auto p : next) { | |
sum += getPercentage(p) / 4; | |
} | |
return sum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment