#include<stdio.h>
#include<string.h>
int a[100005];
int lowbit(int x)
{
return x & (-x);
}
int main()
{
int sum, lim;
while(~scanf("%d%d", &sum, &lim))
{
memset(a, 0, sizeof(a));
int ans = 0;
for(int i = lim; i >= 1; i--)
{
int x = lowbit(i);
if(sum >= x)
{
sum -= x;
ans++;
a[i] = 1;
}
}
if(sum)
printf("-1\n");
else
{
printf("%d\n", ans);
for(int i = 1; i <= lim; i++)
{
if(a[i])
printf("%d ", i);
}
puts("");
}
}
return 0;
}
250 B. The Child and Set
最新推荐文章于 2020-06-06 22:03:38 发布