| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1985 人关注过本帖
标题:[转帖]有兴趣的进来做做^_^
只看楼主 加入收藏
Rank: 1
等 级:新手上路
帖 子:255
专家分:0
注 册:2005-4-25
收藏
得分:0 
100个香至少走三次 150个香蕉最少走7次 200个香蕉至少走13次 与汉诺塔不同

/bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg');}" onmousewheel="return imgzoom(this);" alt="" /> 欢迎加入C语言QQ群698156 我们都是菜鸟乃至新手 坚信有一天定能展翅高飞 因为有着努力的决心 衷心盼望你的到来 让我们一起进步
2005-05-11 12:22
牛虻
Rank: 1
等 级:新手上路
威 望:1
帖 子:472
专家分:0
注 册:2004-10-1
收藏
得分:0 
以下是引用在2005-5-11 12:22:39的发言: 100个香至少走三次 150个香蕉最少走7次 200个香蕉至少走13次 与汉诺塔不同
那你算一下150个香蕉的情况下最多能带几个回家,^_^

土冒
2005-05-11 12:35
Rank: 1
等 级:新手上路
帖 子:255
专家分:0
注 册:2005-4-25
收藏
得分:0 
150个香蕉最多能带26个回家

/bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg');}" onmousewheel="return imgzoom(this);" alt="" /> 欢迎加入C语言QQ群698156 我们都是菜鸟乃至新手 坚信有一天定能展翅高飞 因为有着努力的决心 衷心盼望你的到来 让我们一起进步
2005-05-11 12:42
Rank: 1
等 级:新手上路
帖 子:255
专家分:0
注 册:2005-4-25
收藏
得分:0 
牛虻直接加我们群吧 knoker也在 这样可以即时讨论

/bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg');}" onmousewheel="return imgzoom(this);" alt="" /> 欢迎加入C语言QQ群698156 我们都是菜鸟乃至新手 坚信有一天定能展翅高飞 因为有着努力的决心 衷心盼望你的到来 让我们一起进步
2005-05-11 12:43
Rank: 1
等 级:新手上路
帖 子:255
专家分:0
注 册:2005-4-25
收藏
得分:0 
香蕉增加 就要增加香蕉数除以携带数的值 乘以 2减1次和下一步连起来可以再减一次 比如50个香蕉最少走1次 100个最少走1+4-1-1次 150个最少走1+6-1-1次 我现在就是想到这一步 卡住了 卡在当香蕉除以最大携带数的余数上 没想出如何解决这个余数问题

/bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg');}" onmousewheel="return imgzoom(this);" alt="" /> 欢迎加入C语言QQ群698156 我们都是菜鸟乃至新手 坚信有一天定能展翅高飞 因为有着努力的决心 衷心盼望你的到来 让我们一起进步
2005-05-11 12:49
Rank: 1
等 级:新手上路
帖 子:255
专家分:0
注 册:2005-4-25
收藏
得分:0 

main() { int n,j,i,t,s,l; /*n为倍数 j为余数 i为步数 t为最大携带数 s为香蕉总数 l为总路程*/ printf("请分别输入香蕉总数,离家路程,最大携带量:\n"); scanf("%d%d%d",&s,&l,&t);

while(s!=0) { j=s%t; n=s/t; i=0;

if(j>2) {for(;++i;) if(j-2*i<=i*(2*n-1)+2)break; l-=i;s-=i*(2*n+1);}

else if(j==0) {for(;++i;)if(t<=i*(2*n-1))break; if(t<i*(2*n-1))i--; l-=i;s-=i*(2*n-1);}

else s-=j; }

/*求出猴子把香蕉全部吃完能走多远 大于离家路程多少单位就是可带回的香蕉个数*/ l=-l; if(l<=0)printf("\n猴子带不回香蕉"); else printf("\n猴子最多能带回%d个香蕉",l); getch(); } 做了一下午 终于做出来了 各位看看哈


/bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=5&filename=2005-4/2005427111228529.jpg');}" onmousewheel="return imgzoom(this);" alt="" /> 欢迎加入C语言QQ群698156 我们都是菜鸟乃至新手 坚信有一天定能展翅高飞 因为有着努力的决心 衷心盼望你的到来 让我们一起进步
2005-05-11 17:48
牛虻
Rank: 1
等 级:新手上路
威 望:1
帖 子:472
专家分:0
注 册:2004-10-1
收藏
得分:0 
不错,不错
中午我算的34根是错的
错在我在回去的路没给猴子吃,呵呵

土冒
2005-05-11 18:14
独孤殇
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2005-4-29
收藏
得分:0 
怎么才能告诉那个中点呢?!

2005-05-11 19:58
musicml
Rank: 1
等 级:新手上路
帖 子:273
专家分:0
注 册:2005-4-2
收藏
得分:0 

Every thing is possible.
2005-05-12 23:19
Srin
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2005-5-11
收藏
得分:0 
以下是引用在2005-5-11 17:48:29的发言:

main() { int n,j,i,t,s,l; /*n为倍数 j为余数 i为步数 t为最大携带数 s为香蕉总数 l为总路程*/ printf("请分别输入香蕉总数,离家路程,最大携带量:\n"); scanf("%d%d%d",&s,&l,&t);

while(s!=0) { j=s%t; n=s/t; i=0;

if(j>2) {for(;++i;) if(j-2*i<=i*(2*n-1)+2)break; l-=i;s-=i*(2*n+1);}

else if(j==0) {for(;++i;)if(t<=i*(2*n-1))break; if(t<i*(2*n-1))i--; l-=i;s-=i*(2*n-1);}

else s-=j; }

/*求出猴子把香蕉全部吃完能走多远 大于离家路程多少单位就是可带回的香蕉个数*/ l=-l; if(l<=0)printf("\n猴子带不回香蕉"); else printf("\n猴子最多能带回%d个香蕉",l); getch(); } 做了一下午 终于做出来了 各位看看哈

晕!!这样的C程序也能想出来,,,FFFFFFFFFFFFFFFFFFFF---YOU !!!!!!!!!!!!!!!!!

2005-05-13 05:12
快速回复:[转帖]有兴趣的进来做做^_^
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022665 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved