Lowest Bit

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 34   Accepted Submission(s) : 17
Problem Description
Given an positive integer A (1 <= A <= 100), output the lowest bit of A. 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 should 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 should be 8.
 
Input
Each 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.
 
Output
For each A in the input, output a line containing only its lowest bit.
 
Sample Input
26 88 0
 
Sample Output
2 8
 
Author
SHI, Xiaohan
 
Source
Zhejiang University Local Contest 2005

 #include <stdio.h>
#include <stdlib.h>
#include <string.h> int main()
{
int num,sign,i,j,k,K,sum;
char num_2[],NUM_2[];
while()
{
scanf("%d",&num);
if(num==)break;
itoa(num,num_2,);
sign=strlen(num_2);
for(i=sign-,j=;i>=;i--)
{
if(num_2[i]!='')
{
NUM_2[j]='';
j++;
}
else
{
NUM_2[]='';
NUM_2[j]='\0';
break; }
}
k=strlen(NUM_2);
for(i=,sum=;i<k;i++)
{
sum*=;
}
printf("%d\n",sum); }
return ;
}

Lowest Bit的更多相关文章

  1. [LeetCode] Lowest Common Ancestor of a Binary Tree 二叉树的最小共同父节点

    Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According ...

  2. [LeetCode] Lowest Common Ancestor of a Binary Search Tree 二叉搜索树的最小共同父节点

    Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BS ...

  3. 48. 二叉树两结点的最低共同父结点(3种变种情况)[Get lowest common ancestor of binary tree]

    [题目] 输入二叉树中的两个结点,输出这两个结点在数中最低的共同父结点. 二叉树的结点定义如下:  C++ Code  123456   struct BinaryTreeNode {     int ...

  4. [LeetCode]Lowest Common Ancestor of a Binary Search Tree

    Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BS ...

  5. 数据结构与算法(1)支线任务4——Lowest Common Ancestor of a Binary Tree

    题目如下:https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/ Given a binary tree, fin ...

  6. Lowest Common Ancestor of a Binary Search Tree

    Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BS ...

  7. Lowest Common Ancestor of a Binary Tree

    Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According ...

  8. leetcode 235. Lowest Common Ancestor of a Binary Search Tree

    Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BS ...

  9. leetcode 236. Lowest Common Ancestor of a Binary Tree

    Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According ...

  10. LeetCode 【235. Lowest Common Ancestor of a Binary Search Tree】

    Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BS ...

随机推荐

  1. ramfs/tmpfs: Linux RAM filesystems

    Previously in windows, I uses ramdisk, to accelerate chrome browsing. However, in linux, this is mad ...

  2. mysql索引类型-形式-使用时机-不足之处--注意事项

    一.索引的类型 1.普通索引   增加 create  index  index_name on table(colume(length));                       例子:cre ...

  3. 利用commons-io.jar包中FileUtils和IOUtils工具类操作流及文件

    1.String IOUtils.toString(InputStream input),传入输入流对象,返回字符串,有多重重载,可按需要传参 用例: @Test public void showIn ...

  4. LogFactory缺包异常

    抛出异常: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/loggin ...

  5. 在UE4中使用SVN作为source control工具

    ==========预先处理 1.到这个目录下 2.鼠标在空白处 按住shift键 同时右键 会多出一个 可以打开的cmd 3.输入命令,修改红线部分. me: 登陆svn地址的用户名, URL网址: ...

  6. oracle导入dmp数据库文件

    要用sys账户登录数据库,创建和dmp文件一样的表空间名称 1. 创建表空间 例如: create tablespace test(表空间名称) datafile 'F:\oracle\oradata ...

  7. Java多线程:线程同步与关键字synchronized

    一.同步的特性1. 不必同步类中所有的方法, 类可以同时拥有同步和非同步方法.2. 如果线程拥有同步和非同步方法, 则非同步方法可以被多个线程自由访问而不受锁的限制. 参见实验1:http://blo ...

  8. Quickly Start Listener scripts

    #!/usr/bin/python # # StartListener.py # Simple python script to start a Meterpreter Listener # Auto ...

  9. Apple pay的使用

    Apple pay的使用场景:1.app内:唯品会.   2.线下场景:万达 Apple pay的硬件要求:iphone6 以上  苹果婊 Apple pay的软件要求:国内(应该是)iOS9.2以上 ...

  10. Glusterfs[转]

    原文地址:http://support.huawei.com/ecommunity/bbs/10253434.html 1.      GlusterFS概述 GlusterFS是Scale-Out存 ...