CF750G.New Year and Binary Tree Paths

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The New Year tree is an infinite perfect binary tree rooted in the node 11 . Each node vv has two children: nodes indexed (2v)(2·v) and (2v+1)(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) ( u<=vu<=v ), such that the sum of indices of all nodes along the simple path between uu and vv (including endpoints) is equal to ss . Can you help him and count this value?

输入格式

The only line of the input contains a single integer ss ( 1<=s<=10151<=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 ss .

输入输出样例

  • 输入#1

    10
    

    输出#1

    4
    

说明/提示

In sample test, there are 44 paths with the sum of indices equal to 1010 :

首页