申精,寻找亲和数的程序,亲测通过
freebasic吧
全部回复
仅看楼主
level 6
justintangd 楼主
2014年04月24日 10点04分 1
level 6
justintangd 楼主
这还是刚编出的热气腾腾“臭味十足”的程序,还未剪枝,效率较低,需要天河二号这样的大型计算机来运行~~[真棒]
2014年04月24日 10点04分 2
你竟敢开中文?FBIDE开中文时界面乱糟糟无比= =
2014年04月30日 10点04分
我帮你优化=A=
2014年04月30日 11点04分
level 6
justintangd 楼主
会生成一个文件
2014年04月24日 10点04分 4
level 6
justintangd 楼主
2014年04月24日 10点04分 5
OK,我下载后优化一下
2014年04月30日 10点04分
level 6
justintangd 楼主
现在由于使用的是integer数据类型,所以最大只能找到65535以下的亲和数,等周末再修改。
2014年04月24日 10点04分 6
integer不是 -2147483648 到 2147483647 吗?
2014年04月30日 11点04分
level 3
好厉害![大拇指][大拇指][大拇指]
2014年04月24日 12点04分 7
是挺不错的!
2014年04月30日 10点04分
level 11
终于有人发贴了!我表示很欣慰!(还有,吧主都不在了,还怎么加精。。。)
2014年04月30日 09点04分 8
level 11
LZ肯定和我一样,也是搞信息奥赛的小学生吧。。。我想说一句,你的变量名最好起成英文单词, 最好见名知义,对以后搞程序有很大的帮助~
2014年04月30日 09点04分 9
做的挺好的,继续努力!
2014年04月30日 09点04分
虽然是小学生……但不搞奥赛……我本想劳动节优化……没想到你抢先了……
2014年04月30日 11点04分
回复 justintangd :我一部分信息知识用于搞奥赛,剩下的95%都用来造电脑游戏(有2D有3D有控制台有GUI,全部FreeBASIC制作)
2014年04月30日 11点04分
level 11
在你程序里加了一个检测用时的东东,注意第10行和第35行
测试结果(输入16384)
2014年04月30日 10点04分 11
level 11
优化完成!
2014年04月30日 10点04分 12
比你原来的快多了。。。
2014年04月30日 10点04分
level 11
二期优化结束!
这神了,秒出!对于原来的程序已经优化了200多倍速度!!!
2014年04月30日 11点04分 14
要源码的话LZ请@我一下
2014年04月30日 11点04分
我本来也想用一组一组找的方法提高效率!想到一块了!可是虽然我想法对但是……优化失败……
2014年04月30日 11点04分
回复 justintangd :好吧。。。
2014年04月30日 11点04分
回复 justintangd :还有一点,尽量少给double类型的变量赋值。。。(尽可能少给变量赋值[喷]
2014年04月30日 11点04分
level 11
dim a as integer
dim b as integer
dim c as integer
dim e as integer
dim f as integer
dim h as integer
input a
dim t as double = timer
open "运行结果.txt" for output as #1
for b = 220 to a
e=1
h=1
for c = 2 to sqr(b)
if b mod c=0 then
e=e+c+b/c
end if
next c
for f = 2 to sqr(e)
if e mod f=0 then
h=h+f+e/f
end if
next f
if h=b then
print #1,b,e
print b,e
end if
next b
print "用时";timer-t;"秒"
sleep
close #1
end
2014年04月30日 11点04分 15
level 6
justintangd 楼主
你家电脑好快……
2014年04月30日 11点04分 16
输个小些的数字
2014年05月14日 08点05分
楼上的源码?
2014年05月14日 08点05分
应该比这快多了啊。。。
2014年05月14日 08点05分
level 6
justintangd 楼主
sqr函数是用来干嘛的?我还没学………………………………
2014年04月30日 12点04分 17
平方根
2014年05月14日 08点05分
level 1
求楼主fb的编译器 谢谢
2014年05月17日 06点05分 18
我给的下载地址里有啊!!!!!!!!!!!!!!!!!!那个.exe文件
2014年05月17日 10点05分
回复 justintangd :ok 谢谢
2014年05月17日 10点05分
1