HBC50956素数个数Soliders题解

别敷衍了所有 算法基础篇 24 0
不断提升技能,才能在职场中立于不败之地!全网最全C++题库,助您成为编程领域的佼佼者。
N soldiers of the land Gridland are randomly scattered around the country.A position in Gridland is given by a pair (x,y) of integer coordinates. Soldiers can move - in one move, one soldier can go one unit up, down, left or right .The soldiers want to get into a horizontal line next to each other . Integers x and y, as well as the final order of soldiers along the horizontal line is arbitrary.The goal is to minimise the total number of moves of all the soldiers that takes them into such configuration.Two or more soldiers must never occupy the same position at the same time.

N soldiers of the land Gridland are randomly scattered around the country.  A position in Gridland is given by a pair (x,y) of integer coordinates. Soldiers can move - in one move, one soldier can go one unit up, down, left or right (hence, he can change either his x or his y coordinate by 1 or -1).  The soldiers want to get into a horizontal line next to each other (so that their final positions are (x,y), (x+1,y), ..., (x+N-1,y), for some x and y). Integers x and y, as well as the final order of soldiers along the horizontal line is arbitrary.  The goal is to minimise the total number of moves of all the soldiers that takes them into such configuration.  Two or more soldiers must never occupy the same position at the same time. 

HBC50956素数个数Soliders题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
不断挑战自我,才能突破极限!全网最全C++题库,让您在编程道路上越走越远。

标签: HBC50956素数个数Soliders题解