Good Bye 2016
G
New Year and Binary Tree Paths
Codeforces
3200
原题
← FH →
翻译中…

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)$.

翻译中…

image

翻译中…

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?

翻译中…

Input

翻译中…

The only line of the input contains a single integer $*s*$ ($1 ≤ *s* ≤ 10^{15}$).

翻译中…

Output

翻译中…

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*$.

翻译中…

Note

翻译中…

In sample test, there are $4$ paths with the sum of indices equal to $10$:

翻译中…

image

翻译中…

样例

Input #1
10
Output #1
4
InputCopy OutputCopy
题目信息
题号
750G
所属比赛
时间限制
3 s
内存限制
256 MB
标签
位运算
暴力
组合数学
动态规划

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。