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. Android:dialog去除边框的实现(自带Style的padding)

    public void show(View view) { MyDialog myDialog=new MyDialog(MainActivity.this); myDialog.show(); // ...

  2. Ubuntu操作相关笔记

    Eclipse添加图标 #sudo vim /usr/share/applications/eclipse.desktop 写入以下内容 [Desktop Entry] Name=Eclipse Co ...

  3. Windows下怎么搭建Python+Selenium的自动化环境

    http://jingyan.baidu.com/article/47a29f244aec6bc014239985.html 注意点:配置了环境变量后需要重启电脑

  4. JEMETER 录制

    两种方式: 第一种:badboy工具录制,导入jemeter脚本,导入jemeter.目测支持IE 第二种:代理服务器的方式 1.

  5. 图的存储结构:邻接矩阵(邻接表)&链式前向星

    [概念]疏松图&稠密图: 疏松图指,点连接的边不多的图,反之(点连接的边多)则为稠密图. Tips:邻接矩阵与邻接表相比,疏松图多用邻接表,稠密图多用邻接矩阵. 邻接矩阵: 开一个二维数组gr ...

  6. Delphi的StringReplace[转]

    原文:http://blog.csdn.net/genispan/article/details/4458319 function StringReplace (const S, OldPattern ...

  7. TortoiseGit - 处理冲突

    处理冲突 冲突:远程的master已经被其他人更新到 2repo add 12,但是自己当前的工作区在未pull到最新前,增加了1repo add 12的改动. 右击最新的节点,选择Merge to ...

  8. chapter 13_0 元方法

    通常,Lua中的每个值都有一套预定义的操作集合. 例如:可以将数字相加.可以连接字符串.可以在table中插入一对key-value等. 但是无法将两个table相加,无法对函数作比较,或无法调用一个 ...

  9. Lynis 2.2.0 :面向Linux系统的安全审查和扫描工具

    Lynis是一款功能非常强大的开源审查工具,面向类似Unix/Linux的操作系统.它可以扫描系统,查找安全信息.一般的系统信息.已安装软件及可用软件信息.配置错误.安全问题.没有设密码的用户帐户.错 ...

  10. python 函数/列表的应用

    enumerate 函数用于遍历序列中的元素以及它们的下标: >>> for i,j in enumerate(('a','b','c')): print i,j 0 a1 b2 c ...