A10703 | New Year and Binary Tree Paths
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The New Year tree is an infinite perfect binary tree rooted in the node $1$ . Each node $v$ has two children: nodes indexed $(2·v)$ and $(2·v+1)$ .
Polar bears love decorating the New Year tree and Limak is no exception. As he is only a little bear, he was told to decorate only one simple path between some pair of nodes. Though he was given an opportunity to pick the pair himself! Now he wants to know the number of unordered pairs of indices $(u,v)$ ( $u<=v$ ), such that the sum of indices of all nodes along the simple path between $u$ and $v$ (including endpoints) is equal to $s$ . Can you help him and count this value?
Polar bears love decorating the New Year tree and Limak is no exception. As he is only a little bear, he was told to decorate only one simple path between some pair of nodes. Though he was given an opportunity to pick the pair himself! Now he wants to know the number of unordered pairs of indices $(u,v)$ ( $u<=v$ ), such that the sum of indices of all nodes along the simple path between $u$ and $v$ (including endpoints) is equal to $s$ . Can you help him and count this value?
输入格式
The only line of the input contains a single integer $s$ ( $1<=s<=10^{15}$ ).
输出格式
Print one integer, denoting the number of unordered pairs of nodes indices defining simple paths with the sum of indices of vertices equal to $s$ .
输入输出样例
输入 #1
10
输出 #1
4
In sample test, there are $4$ paths with the sum of indices equal to $10$ :


C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted