-
Notifications
You must be signed in to change notification settings - Fork 2
/
numbertree.cpp
85 lines (79 loc) · 1.48 KB
/
numbertree.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <ctype.h>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <unordered_map>
#define EPSILON 0.00001
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
vector<string> pySplit(string & splitString, char seperator = ' ')
{
int endIndex = 0;
vector<string > seperated;
seperated.push_back("");
for (unsigned int i = 0; i < splitString.size(); i++)
{
if (splitString[i] == seperator)
{
endIndex++;
seperated.push_back("");
}
else
{
seperated[endIndex] += splitString[i];
}
}
return seperated;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout << fixed << setprecision(0);
ll i, j, k;
ull h;
string path;
vector<string> args;
ll currentLoc = 1;
getline(cin, path);
args = pySplit(path);
if(args.size() == 1)
{
h = stoi(args[0]);
}
else
{
h = stoi(args[0]);
path = args[1];
}
for(auto letter : path)
{
if(letter == 'L')
{
currentLoc *= 2;
}
else
{
currentLoc *= 2;
currentLoc++;
}
}
//cout << currentLoc << "\n";
h = pow(2, h);
h *= 2;
cout << h - currentLoc << "\n";
return 0;
}