Distributed Optimal Strategies for UAV Formation