Hangzhou Electric HDU 1196 Lowest Bit

Source: Internet
Author: User

Lowest Bit Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 9052 Accepted Submission (s): 6656


Problem Descriptiongiven an positive integer a (1 <= a <=), output the lowest bit of a.

For example, given a = +, we can write a in binary form as 11010, so the lowest bit of a is ten, so the output should be 2 .

Another example goes like this:given a = to, we can write A in binary form as 1011000, so the lowest bit of The output should is 8.

Inputeach line of input contains only an integer a (1 <= a <= 100). A line containing "0" indicates the end of input, and this line is not a part of the input data.

Outputfor each A in the input, output A line containing only it lowest bit.

Sample Input
26880

Sample Output
28

Authorshi, Xiaohan, the grass in the big night.
#include <iostream> #include <cmath>using namespace Std;int main () {int A;while (cin>>a,a) {int count=0 ;        while (a%2==0) {count++;a/=2;} Cout<<pow (2,count) <<endl;} return 0;}

Hangzhou Electric HDU 1196 Lowest Bit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.