add time cost in Promblem#4, slove Problem#5 by half brute force