Hdu1196 lowest Bit

Source: Internet
Author: User

Lowest bittime limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others) Total submission (s): 7728 accepted submission (s): 5674

Problem descriptiongiven an positive integer A (1 <= A <= 100), output the lowest Bit Of.

For example, given a = 26, we can write a in binary form as 11010, so the lowest Bit Of A is 10, so the output shocould be 2.

Another example goes like this: Given A = 88, we can write a in binary form as 1011000, so the lowest Bit Of A is 1000, so the output shocould be 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 its lowest Bit.
 
Sample Input
26880
 
Sample output
28
This knowledge point is required for tree arrays.

#include <stdio.h>int main(){int n;while(scanf("%d", &n), n){printf("%d\n", n & (-n));}return 0;}


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.