题目: http://acm.hdu.edu.cn/showproblem.php?pid=1196
水题:;
#include <cmath> #include <cstdio> #include <iostream> using namespace std; int DeAl(int a, int b) { int ans = 1; while(b) { if(b & 1) ans = ans * a; b /= 2; a *= a; } return ans; } int main() { int n; while(~scanf("%d", &n), n) { int sum = 0; while(n) { int TeMp = n%2; if(TeMp == 1) break; sum++; n /= 2; } // int Q = pow(2, sum); int Q = DeAl(2, sum); printf("%d\n", Q); } return 0; }
浙公网安备 33010602011771号