Problem | 2453 | User | jereneal20 |
Memory | 388K | Time | 125MS |
Language | GCC | Result | Accepted |
#include <stdio.h> int bincount(int X); int main() { int N,n,k=0; while(1){ scanf("%d",&N); if(N==0) break; k=bincount(N); for(n=N+1;k!=bincount(n);n++){} printf("%d\n",n); } return 0; } int bincount(int X) { int nf,kf=0; for(nf=X;nf>0;nf=nf>>1){ if(nf%2==1) kf++; } return kf; }