- C - Submask
-TJ
- 2024-6-18 17:00:01 @
/* created by chjshen, date: 2024-05-08 16:45 */
#include <cstdio>
#include <iostream>
#include <set>
using namespace std;
long long n;
set<long long> ms;
void f(long step, long long x)
{
if (((1LL << step) | x) > n) return;
if ((1LL << step) & n)
{
ms.insert(x);
f(step + 1, x);
ms.insert((long long) (x | (1LL << step)));
f(step + 1, x | (1LL << step));
}
else
{
ms.insert(x);
f(step + 1, x);
}
}
void handle(void)
{
f(0, 0);
ms.insert(0);
for (auto c : ms)
{
cout << c << endl;
}
}
void initInput(void)
{
ios::sync_with_stdio(0);
cin >> n;
}
int main(void)
{
initInput();
handle();
return 0;
}
0 条评论
目前还没有评论...
信息
- ID
- 3758
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- 递交数
- 129
- 已通过
- 27
- 上传者