当前位置:网站首页>J. Balanced Tree
J. Balanced Tree
2022-06-11 03:29: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;
}
边栏推荐
- Reasons why Chinese comments cannot be written in XML
- Oppo reno6 turned sour by "inner roll"
- Start QQ through the program to realize automatic login
- The key data of music genuine rate is missing. What is the odds of Netease cloud music IPO?
- 被“内卷”酸翻的OPPO Reno6
- 亚马逊测评自养号,小白应该如何开始?
- Artalk | how to build a domestic hyperfusion evolutionary base with minimum investment?
- Promise使用
- Vocabulary Construction -- code completion fast food tutorial (3) - word segmentation
- 潮玩力真火力!年轻人第一台巨幕影院?酷开电视Max 86“庞然来袭
猜你喜欢

canvas交互式星星动画背景js特效

UML series articles (28) architecture modeling - collaboration

音乐正版率关键数据缺失,网易云音乐IPO胜算几何?

Mazhiqiang: research progress and application of speech recognition technology -- RTC dev Meetup

Tweenmax colorful ball bouncing animation

PostgreSQL source code learning (22) - fault recovery ③ - transaction log registration

多线程四部曲之pthread

net::ERR_ FILE_ NOT_ Found error

Disk quota exceeded

File compositor
随机推荐
Tweenmax colorful ball bouncing animation
RequestContextHolder
Log4j use
Canvas rotation drawing H5 animation JS effect
window10安装keras
File file = new file ("test.txt") file path
iQOO 8实测上手体验:王者归来,从不高调
多线程四部曲之pthread
postgresql 捕获函数中的异常
WEB上传文件预览
Mavros controls UAV to conduct binocular slam in gazebo environment
OpenGl第九章 光照贴图
The key data of music genuine rate is missing. What is the odds of Netease cloud music IPO?
GD32 can发送报no mailbox 故障
svg实现纸飞机自由的飞翔动画
B_ QuRT_ User_ Guide(18)
正则表达式
SSL库选择
【云原生】什么是微服务?怎么搭建?手把手教你搭建第一个微服务(框架)
实现发布订阅模式-----手撕js系列