吸血鬼号码在这里定义https://en.wikipedia.org/wiki/Vampire_number.数字V是吸血鬼号码,如果:
我提出了一个解决方案,
strV = sort(toString(V))
for factor <- pow(10, N/2) to sqrt(V)
if factor divides V
X <- factor
Y <- V/factor
if X and Y have trailing zeros
continue
checkStr = sort(toString(X) + toString(Y))
if checkStr equals strV return true
Run Code Online (Sandbox Code Playgroud)
另一种可能的解决方案是置换由V表示的字符串并将其分成两半并检查它是否是吸血鬼号码.哪一个是最好的方法呢?
给定一个包含n个元素的数组,如何在给定范围索引i中找到大于或等于给定值(x)的元素个数到O(log n)复杂度中的索引j?
查询的形式为(i,j,x),这意味着从数组中的第i个到第j个元素中查找大于x的元素数
数组未排序.i,j&x对于不同的查询是不同的.数组的元素是静态的.编辑:i,j,x对于不同的查询都可以是不同的!
我想用python下载视频.我尝试使用youtube-dl,但不支持我想从中下载视频的网站.如何在Python中下载视频.首先,我尝试通过以下链接获取我想从keepvid.com下载的视频的直接链接http://www.kmcgraphics.com/bits-of-code/how-to-get-the-direct-url -path-to-flv-video-files-on-youtube-for-free /.我得到以下链接http://www.animefun.com/dl/googDev.php?url=/108994262975881368074/Po270当我尝试运行以下代码时,我收到错误.
import urllib
test=urllib.URLopener()
test.retrieve("http://www.animefun.com/dl/googDev.php?url=/108994262975881368074/Po270.flv","testout.flv")
Run Code Online (Sandbox Code Playgroud)
错误:
Traceback (most recent call last):
File "downl.py", line 14, in <module>
test.retrieve("http://www.animefun.com/dl/googDev.php?url=/108994262975881368074/Po270.flv","testout.flv")
File "/usr/lib/python2.7/urllib.py", line 240, in retrieve
fp = self.open(url, data)
File "/usr/lib/python2.7/urllib.py", line 208, in open
return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py", line 359, in open_http
return self.http_error(url, fp, errcode, errmsg, headers)
File "/usr/lib/python2.7/urllib.py", line 376, in http_error
return self.http_error_default(url, fp, errcode, errmsg, headers)
File "/usr/lib/python2.7/urllib.py", line 381, in http_error_default
raise IOError, ('http error', errcode, errmsg, headers) …Run Code Online (Sandbox Code Playgroud)