(HDU)1196 -- Lowest Bit(最低位)

题目链接:http://vjudge.net/problem/HDU-1196

二进制最低位可以用位运算,也可以模拟这个步骤。

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cmath>
 4 #include <algorithm>
 5
 6 using namespace std;
 7
 8 int main()
 9 {
10     int A,t;
11     while(scanf("%d",&A),A)
12     {
13         t=1;
14         while(A)
15         {
16             if(A%2==1)break;
17             A/=2;
18             t*=2;
19         }
20         printf("%d\n",t);
21     }
22     return 0;
23 }
时间: 2024-12-24 03:28:43

(HDU)1196 -- Lowest Bit(最低位)的相关文章

HDU 1196 Lowest Bit (数位)

Lowest Bit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8166    Accepted Submission(s): 5998 Problem Description Given an positive integer A (1 <= A <= 100), output the lowest bit of A. For

杭电 HDU 1196 Lowest Bit

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 Description Given an positive integer A (1 <= A <= 100), output the lowest bit of A. For

hdu 1196 Lowest Bit

#include<stdio.h> int main() { int i,n,a[10000],sum,j; while(~scanf("%d",&n)&&n) { sum=1; for(i=0;;i++) { a[i]=n%2; n=n/2; if(a[i]) break; } for(j=1;j<=i;j++) sum=sum*2; printf("%d\n",sum); } return 0; }

Hdoj 1196 Lowest Bit 【&amp;】

Lowest Bit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 9273 Accepted Submission(s): 6824 Problem Description Given an positive integer A (1 <= A <= 100), output the lowest bit of A. For examp

HDOJ 1196 Lowest Bit

[题意]:给一个数,找其二进制的最低位n,输出2^n.比如 11010为10输出2,11000 is 1000输出8. 思路:按照二进制算法来就行.注意是%2不是/2. [AC代码]: #include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namesp

hdu 2028 Lowest Common Multiple Plus(最小公倍数)

Lowest Common Multiple Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 34980    Accepted Submission(s): 14272 Problem Description 求n个数的最小公倍数. Input 输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数. Out

hdu 2028 Lowest Common Multiple Plus

Problem Description 求n个数的最小公倍数. Input 输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数. Output 为每组测试数据输出它们的最小公倍数,每个测试实例的输出占一行.你可以假设最后的输出是一个32位的整数. Sample Input 2 4 6 3 2 5 7 Sample Output 12 70 思路:水题.题目要求32位整数,所以使用unsigned int. 代码: #include <iostream> #include 

Lowest Bit------HDOJ杭电1196(想法很重要)

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:

杭电 HDU ACM 2028 Lowest Common Multiple Plus

Lowest Common Multiple Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 39183    Accepted Submission(s): 16144 Problem Description 求n个数的最小公倍数. Input 输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数. Ou