poj2453
简单题
View Code
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
using namespace std;
int count(int x)
{
int ret = 0;
while (x > 0)
{
if (x % 2 == 1)
ret++;
x /= 2;
}
return ret;
}
int main()
{
//freopen("D:\\t.txt", "r", stdin);
int n;
while (scanf("%d", &n) != EOF && n != 0)
{
int cnt = count(n);
while (n++)
if (cnt == count(n))
{
printf("%d\n", n);
break;
}
}
return 0;
}