LeeBlog

导航

2011年3月12日 #

hdu 1196 Lowest Bit

摘要: 这题题意是,把数换成二进制,然后从右边数起第一个为1的位置n,然后最小数就是2*( n - 1 ),开始还想用短除法,不过小白说这里可以用A&-A,就可以得出来;#include<stdio.h>int main( ){ int x,y,z,n; while( scanf( "%d",&x ) ,n ) { z = 1; int y = 0; while( y != 1 ) { y = x % 2; x = x / 2; z *= 2; } printf( "%d\n",z / 2 ); } return 0;} #inclu 阅读全文

posted @ 2011-03-12 23:19 LeeBlog 阅读(186) 评论(0) 推荐(0) 编辑

hdu 1108 最小公倍数

摘要: #include<stdio.h>int cal( int x,int y ){ return y ? cal( y , x % y ) : x;//求最大公约数}int main( ){ int x,y,z; while( scanf( "%d%d",&x,&y ) ) { z = x * y / cal ( x , y ); printf( "%d\n",z ); } return 0;} 阅读全文

posted @ 2011-03-12 22:14 LeeBlog 阅读(494) 评论(0) 推荐(0) 编辑