2022 Jiangsu Collegiate Programming Contest
Solution
Code
#define ll unsigned long long int
ll dfs(ll x, ll a, ll b, ll c)
{
if (x == 0) return 0;
if (x == 1) return c;
if (x & 1) return dfs(x >> 1, a * 2 + b, b, c + b);
else return dfs(x >> 1, a, a + b * 2, c + a);
}
int main()
{
IOS;
int T; cin >> T;
while (T--)
{
ll ans = 1;
ll n; cin >> n;
ll c = dfs(n, 1, 0, 0);
if (c >= 64) ans = 0;
else ans <<= c;
cout << ans << endl;
}
return 0;
}