草庐IT

abundant

全部标签

c++ - Project Euler #23,在程序中找不到问题

链接:http://projecteuler.net/problem=23Aperfectnumberisanumberforwhichthesumofitsproperdivisorsisexactlyequaltothenumber.Forexample,thesumoftheproperdivisorsof28wouldbe1+2+4+7+14=28,whichmeansthat28isaperfectnumber.Anumberniscalleddeficientifthesumofitsproperdivisorsislessthannanditiscalledabundan

go - 为什么 Go map vs slice 性能在这里有 10 倍的速度差异

我刚刚解决了ProjectEuler的问题23,但我注意到map[int]bool和[]bool在性能方面存在很大差异。我有一个函数可以对一个数的真因数求和:funcdivisorsSum(nint)int{sum:=1fori:=2;i*i然后主要我是这样做的:funcmain(){start:=time.Now()deferfunc(){elapsed:=time.Since(start)fmt.Printf("%s\n",elapsed)}()n:=28123abundant:=[]int{}fori:=12;ii{abundant=append(abundant,i)}}sum

go - 为什么 Go map vs slice 性能在这里有 10 倍的速度差异

我刚刚解决了ProjectEuler的问题23,但我注意到map[int]bool和[]bool在性能方面存在很大差异。我有一个函数可以对一个数的真因数求和:funcdivisorsSum(nint)int{sum:=1fori:=2;i*i然后主要我是这样做的:funcmain(){start:=time.Now()deferfunc(){elapsed:=time.Since(start)fmt.Printf("%s\n",elapsed)}()n:=28123abundant:=[]int{}fori:=12;ii{abundant=append(abundant,i)}}sum