303897: CF750G. New Year and Binary Tree Paths

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

New Year and Binary Tree Paths

题意翻译

一颗无穷个节点的完全二叉树。 求有多少条树上的简单路径编号和为 $s$。 $s \leq 10^{15}$。

题目描述

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) $ . ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF750G/5f3fba6843b56e8c74120fa68d53319463f26696.png)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 $ : ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF750G/c83b62a188e719702078b419fb6e934500dacd07.png)

Input

题意翻译

一颗无穷个节点的完全二叉树。 求有多少条树上的简单路径编号和为 $s$。 $s \leq 10^{15}$。

加入题单

上一题 下一题 算法标签: