

1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 5 int main() 6 { 7 int n; 8 while (scanf("%d",&n) != EOF) { 9 int cnt(0); 10 while (n) { 11 cnt += (n&1); 12 n >>= 1; 13 } 14 printf("%d\n",(1<<cnt)); 15 } 16 return 0; 17 }
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 5 int main() 6 { 7 int n; 8 while (scanf("%d",&n) != EOF) { 9 int cnt(0); 10 while (n) { 11 cnt += (n&1); 12 n >>= 1; 13 } 14 printf("%d\n",(1<<cnt)); 15 } 16 return 0; 17 }
转载于:https://www.cnblogs.com/devtang/archive/2012/08/09/2630786.html