solve it by two ways, one in BF, the other use STL, more faster and elegant, goood