1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#include <cstdio>

int main()
{
  int n, i=0, s=0;
  scanf("%i", &n);
  while (s<n) s+=__builtin_popcount(++i);
  printf("%i\n", i-(s>n));
  for (; i>0; i--)
  {
    int c=__builtin_popcount(i);
    if (c>s-n) printf("%i%c", i, "\n "[i>1]); else if (c<s-n) printf("!"); else s-=c;
  }
  return 0;
}