--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
---
您收到此邮件是因为您订阅了 Google 网上论坛的“Shanghai Linux User Group”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 shlug+un...@googlegroups.com。
要查看更多选项,请访问 https://groups.google.com/groups/opt_out。
您收到此邮件是因为您订阅了 Google 网上论坛“Shanghai Linux User Group”中的主题。
要退订此主题,请访问 https://groups.google.com/d/topic/shlug/uKF-GeWzV1Y/unsubscribe。
要退订此论坛及其所有主题,请发送电子邮件到 shlug+un...@googlegroups.com。
要查看更多选项,请访问 https://groups.google.com/groups/opt_out。
你为什么scanf 了一个 r, 而又不用呢?
您收到此邮件是因为您订阅了 Google 网上论坛“Shanghai Linux User Group”中的主题。
要退订此主题,请访问 https://groups.google.com/d/topic/shlug/uKF-GeWzV1Y/unsubscribe。
要退订此论坛及其所有主题,请发送电子邮件到 shlug+un...@googlegroups.com。
要查看更多选项,请访问 https://groups.google.com/groups/opt_out。
实在无力吐槽了。。。
算法的最高境界不就是直接手算出公式(最终结果),然后然计算机代入一下吗?
不是质数。
假如2^n+1能被3整除,
那么,4*2^n+4也能被3整除,
所以2^(n+2)+1能被3整除,
又因为2^1+1能被3整除,
所以2的奇数次方+1都能被3整除。
2^65536+1是奇数,
所以2^(2^65536+1)+1能被3整除,
故不是质数。
--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
---
您收到此邮件是因为您订阅了 Google 网上论坛的“Shanghai Linux User Group”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 shlug+un...@googlegroups.com。
要查看更多选项,请访问 https://groups.google.com/groups/opt_out。
>我算出来的结果是4*(pi)*r*r/5我也觉得结果是3.2pi我是计算黑色圆环的面积,然后 r/4 递归累加,当r足够小时结束递归。用Python写的,不知道对不对radius = 2.0def area(r):if r < 0.0000000001:return 0else:return 0.75 * r * r + area(r/4)print area(radius)
算法错 + int错int 算个毛啊?你知道float 和int 的区别吗?
而且你想用是用monte carlo simulation 做还是用数学极限/积分做?
求指教,该怎么写呢?
在 2013年6月17日星期一UTC+8下午2时17分17秒,Soahc Lanrete写道:
减了。
但是他不应该写(ds/2)
2013/6/17 none_nobody <lyx...@gmail.com>:
> 浮点不能比较0,
>
> 要比较 小于某个值,比如0.0000000001 ,后面算面积乘方就没有了。
>
> 还有,你那个flag = flag * (-1)
>
> 没说减去白色部分面积啊。
>
>
>
>
> On Monday, June 17, 2013 1:53:02 PM UTC+8, Q Zhongyu wrote:
>>
>>
>> 对啊!我吧ds的类型改成double也不行,出来的还是一对莫名其妙的答案,所以改回int类型了,这个递归当ds==0的时候就有出口了,但是貌似怎么也达到不到0。
>>
> --
> -- You received this message because you are subscribed to the Google Groups
> Shanghai Linux User Group group. To post to this group, send email to
> sh...@googlegroups.com. To unsubscribe from this group, send email to
> shlug+un...@googlegroups.com. For more options, visit this group at> https://groups.google.com/d/forum/shlug?hl=zh-CN> 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 shlug+un...@googlegroups.com。
> ---
> 您收到此邮件是因为您订阅了 Google 网上论坛的“Shanghai Linux User Group”论坛。
> 要查看更多选项,请访问 https://groups.google.com/groups/opt_out。
>
>
--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
---
您收到此邮件是因为您订阅了 Google 网上论坛的“Shanghai Linux User Group”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 shlug+un...@googlegroups.com。
要查看更多选项,请访问 https://groups.google.com/groups/opt_out。
--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
---
您收到此邮件是因为您订阅了 Google 网上论坛的“Shanghai Linux User Group”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到 shlug+un...@googlegroups.com。
要查看更多选项,请访问 https://groups.google.com/groups/opt_out。
/* 半径为r的黒圆,里面有个半径r/2的白圆,白圆里又有一个半径为r/4的黒圆,此黒圆里又有一个半径为r/8的白圆入错重复下去,问黑色部分的面积为多少?*******************************************************************************************标准答案输入 2 输出 4pi 下面是我的算法*/# include <stdio.h>int sm(int ds,int sum,int flag);int main(){int r;printf("请输入圆的半径:");scanf("%d",&r);printf("%d\n",r);printf("%dpi\n",sm(r,r*r,-1));return 0;}int sm(int ds,int sum,int flag){if (ds == 0)return sum;elseprintf("递归中的sum=%d\n",sum);return sm(ds / 2,sum + (ds / 2) * (ds / 2) * flag,flag*(-1));}