Distributed Solutions for a Class of Multi-agent Optimization Problems