defpone(p, u): c = 0 for x in xrange(2, int(sqrt(p)) + 1): if p % x == 0and x + p / x < u: c += 1 return c >= 2
defsone(s, u): for x in xrange(2, s / 2): y = s - x ifnot pone(x * y, u): returnFalse returnTrue
defptwo(p, u): c = 0 for x in xrange(2, int(sqrt(p)) + 1): if p % x == 0and x + p / x < u: y = p / x if sone(x + y, u): c += 1 return c == 1 defstwo(s, u): c = 0 for x in xrange(2, s / 2): y = s - x if ptwo(x * y, u): c += 1 return c == 1
if __name__ == "__main__": u = 100 for x in xrange(2, u / 2): for y in xrange(x + 1, u - x): p = x * y s = x + y if pone(p, u) and sone(s, u) and ptwo(p, u) and stwo(s, u): print"x:%d, y:%d, p:%d, s:%d " % (x, y, p, s)
因为项目需要用到分页功能,所以需要用到SetLimits函数,结果就出现了Error: searchd error: offset out of bounds (offset=9500, max_matches=1000)
于是找原因,发现配置文件中有max_matches这个选项,于是将它改为10000,可是依然出现Error: searchd error: offset out of bounds (offset=9500, max_matches=1000)错误,真是莫名其妙的错误,仔细看了SetLimits的函数说明以及SphinxClient.java,才知道使用SetLimits这个函数时,如果没有提供max_matches这个参数的值,则max_matches默认为1000,而9500超过了1000,所以溢出了。