#include <iostream> #include <cstdio> #include <cmath> using namespace std; int main(){ int A,cnt,top; while(scanf("%d",&A)!=EOF&&A!=0){ char stk[10]; top=0; if(A%2!=0){ printf("%d\n",1); continue; }else if(A%2==0){ while(A%2==0){ A=A/2; stk[top++]='0'; } stk[top++]='1'; cnt=0; while(top--){ if(stk[top]=='0'){ cnt++; } } int ret=pow(2,cnt); printf("%d\n",ret); } } return 0; } |
Double click to view unformatted code.