No.420 mod2 Recurrence Relation
問題文最終更新日: 2026-06-25 15:04:08
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 148
(順位表)
の他の問題:
Problem Statement
The following recurrence relation is given.
$f(0) \ = \ 0$
$f(n) \ = \ f(n/2) \ + \ (n \ mod \ 2)$
$(n$ is an integer$、n/2$ is rounded down to an integer$)$
Among $0 \le n \le 2^{31}-1 \ (2147483647)$,
find the number of $n$ such that $f(n) \ = \ x \ $ and the sum of such $n$.
Input
$x$
An integer $x$ is given on $1$ line.
$0 \le x \le 10^9$
Output
Output the number of $n$ such that $f(n)=x$ and the sum of such $n$, separated by a space.
Sample
Sample 1
Input
5
Output
169911 58851789346035
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
はむこ