xieguiguan 发表于 2005-9-13 16:08:21

三米

liudatou3 发表于 2005-9-15 19:16:23

大哥,怎么做

hebestar 发表于 2005-10-3 07:46:01

先记下来机器模拟一下再回来

hebestar 发表于 2005-10-3 08:40:30

<P>在半径为1.5,一步走1的时候结果是3.528左右,还是比较稳定,大概正负0.003,其他参数的时候没算</P>
<P>这段程序可以近似模拟,如有错误欢迎指正<IMG src="http://www.shumo.com/bbs/Skins/Default/emot/em20.gif"></P>
<P>#include&lt;iostream&gt;<br>#include&lt;cstdlib&gt;<br>#include&lt;ctime&gt;<br>#include&lt;cmath&gt;<br>using namespace std;<br>bool IsOut(const double x,const double y);<br>const double R=1.5;<br>const double step=1;<br>const long MAX=10000000;<br>void main()<br>{<br>double x=0;         //初始位置<br>double y=0;<br>double new_x;<br>double new_y;<br>double alpha;<br>double count=0;<br>srand(time(0));<br>for(int i=0;i&lt;MAX;i++)<br>{<br><br>for(;;)<br>{<br>   if(!IsOut(x,y))<br>   {<br>    alpha=(double(rand())/RAND_MAX)*361;<br>    new_x=step*cos(alpha)+x;<br>    new_y=step*sin(alpha)+y;<br>    x=new_x;<br>    y=new_y;<br>    count++;<br>   }<br>   else<br>    break;<br>}<br>x=0;<br>y=0;<br>}<br>cout&lt;&lt;"平均需要走"&lt;&lt;count/MAX&lt;&lt;"步"&lt;&lt;endl;<br>}<br>bool IsOut(const double x,const double y)<br>{<br>if((x*x+y*y)&lt;=R*R)<br>return false;<br>else<br>return true;<br>}</P>
[此贴子已经被作者于2005-10-3 12:29:32编辑过]

hebestar 发表于 2005-10-3 08:42:12

上面是求的平均值   取整数就是4
[此贴子已经被作者于2005-10-3 12:29:58编辑过]

still007 发表于 2005-10-3 19:44:42

难!!!

桥联23 发表于 2005-10-10 04:51:06

至少多过3个钟,但是没有规律走,麻烦

dailiangren 发表于 2005-10-17 04:31:29

<P>可以走成正六边形,这个时候永远也走不出去。</P>
<P>很多时候走不出去。</P>

星空 发表于 2005-12-11 21:17:01

有难度!

277490252 发表于 2006-1-16 00:41:43

收录中.......
页: 1 [2] 3 4
查看完整版本: 关于一只蚂蚁的数学难题 [ZT]