#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#define ll long long
#define elif else if
using namespace std;
int main()
{
char a;
char array[1026] = { 0 };
int p = 2;
cin >> a;
while (cin >> a)
{
if (a == '#')
{
array[p] = a;
if (p % 2 == 0)
++p;
else
{
do
{
p = (p - 1) / 2;
} while (p % 2 == 1);
++p;
}
}
else
{
array[p] = a;
p *= 2;
}
}
int max = 0;
for (int i = 0; i < 1026; ++i)
{
if (array[i] == '#' || array[i] == 0)
;
else
max = i;
}
int num = 0;
while (max/=2)
{
++num;
}
cout << num;
return 0;
}
东华大学oj二叉树:二叉树的层数
最新推荐文章于 2024-07-15 22:10:26 发布