# HDU 5573 Binary Tree 2015上海现场赛B题

2.确定pos

Problem : 5573 ( Binary Tree ) Judge Status : Accepted
RunId : 15788211 Language : G++ Author : qsqx

#include <iostream>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <string.h>
#define ll long long
#define forn(i,n) for(int i=0;i<(n);++i)
#define rep(i,n) for(int i=1;i<=(n);++i)
#define pii pair<int,int>
#define mp(x,y) make_pair((x),(y))
using namespace std;
ll res = 0;
while (pos) {
res += pos;
else
res -= pos;
pos >>= 1;
}
return res;
}
vector <pair<ll , char> >res;
res.clear();
while (pos) {
res.push_back(mp(pos, '+'));
else
res.push_back(mp(pos, '-'));
pos >>= 1;
}
int len = res.size();
for (int i = len - 1; i >= 0; --i) {
printf("%lld %c\n", res[i].first, res[i].second);
}
}
void solve() {
ll n;
int k;
cin >> n >> k;
for (int t = 1; t <k;++t) {
if (f(mask | (1LL << t), 1LL << (k - 1))<=n) {
}
}
ll pos = 1LL << (k - 1);
for (int t = k - 2; t >= 0; --t) {
if (f(mask, pos | (1LL << t)) <= n)
pos |= (1LL << t);
}

}