#abc269c. C - Submask
C - Submask
Score : points
问题陈述
给定一个非负整数 。按升序打印满足以下条件的所有非负整数 。
- 在 的二进制表示中包含数字 的位置集合是 的二进制表示中包含数字 的位置集合的子集。
- 即,对于每一个非负整数 ,下列条件成立:如果 中在 "" 位置上的数字为 ,那么 中在 位置上的数字也为 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a non-negative integer . Print all non-negative integers that satisfy the following condition in ascending order.
- The set of the digit positions containing in the binary representation of is a subset of the set of the digit positions containing in the binary representation of .
- That is, the following holds for every non-negative integer : if the digit in the "s" place of is , the digit in the s place of is .
Constraints
- is an integer.
- In the binary representation of , at most digit positions contain .
Input
The input is given from Standard Input in the following format:
Output
Print the answer as decimal integers in ascending order, each in its own line.
Sample Input 1
11
Sample Output 1
0
1
2
3
8
9
10
11
The binary representation of is .
The non-negative integers that satisfy the condition are:
Sample Input 2
0
Sample Output 2
0
Sample Input 3
576461302059761664
Sample Output 3
0
524288
549755813888
549756338176
576460752303423488
576460752303947776
576461302059237376
576461302059761664
The input may not fit into a -bit signed integer.
update @ 2024/3/10 11:20:52