当前位置:网站首页>J. Balanced Tree
J. Balanced Tree
2022-06-11 03:21:00 【to cling】
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;
}
边栏推荐
猜你喜欢
随机推荐
Lombok use
postgresql源码学习(二十)—— 故障恢复①-事务日志格式
PostgreSQL source code learning (18) -- mvcc ③ - creating (obtaining) snapshots
Detailed explanation of unity project optimization (continuous supplement)
單片機通信數據延遲問題排查
Opencv实现纵横比保持的图像缩放
被“内卷”酸翻的OPPO Reno6
多线程交替输出AB
Lecturer paging query_ Instructor condition query with page
多线程四部曲之pthread
PostgreSQL source code learning (XX) -- fault recovery ① - transaction log format
postgresql源码学习(十七)—— MVCC②-快照与隔离级别简介
Computer vision (AI) interview
Logical deletion_ Swagger2 framework integration
计算机视觉(AI)面试大全
C language pointer
对象存储Minio使用教程
配置用命令行编译的环境-MSVC
Stringutils string tool class used by FreeMarker to create templates
If the source code of the home page module is not separated ----- > nanny level source code analysis (1)









