这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1196
注意<<与&的优先级。
代码:
// Author: Tanky Woo
// Blog: www.WuTianQi.com
// Title: HDOJ 1196 Lowest Bit
// About: 水题
#include
#include
#include
#include
#include
using namespace std;
int fun(int n)
{
int ans = 1;
while((n & 1) == 0)
{
ans *= 2;
n = n >> 1;
}
return ans;
}
int main()
{
int n;
while(cin >> n && n)
{
cout << fun(n) << endl;
}
}