JonsenElizee

Software Developing Blog

"An idea is fragile . It can be killed by a scornful smile or a yawn .It can be mound down by irony and scared to death by a cold look."
"Most cultures throughout human history have not liked creative individuals .They ignore them or kill them.It is a very efficient way of stopping creativity."

------Advertising boss Charles Browe and Howard Gardner ,professor at Harvard

   :: 首页 :: 新随笔 ::  ::  :: 管理 ::
There are y ball with a bad one between them.
all the ball are the same look.
now, give you a balance, how many times do you need to pick out the bad one?

My resolution: need Ball(y) times to pick out the bad one.

#include <stdio.h>
#include 
<math.h>

int Ball(int y)
{
    
if(y <= 3return 1;
    
return 1+Ball( y/3 * 3 == y ? y/3 : y/3 +1 );
}
int main()
{
    
int i = 0;
    
for(i = 2; i < 200; i++) {
        printf(
"Ball(%3d)=%d \t", i, Ball(i));
        
if(i%5 == 0) puts("");
    }
    puts(
"");
    
return 0;
}



posted on 2010-10-29 09:21 JonsenElizee 阅读(1368) 评论(0)  编辑 收藏 引用 所属分类: Data Structures & Algorithms

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


By JonsenElizee