Exact diffusion strategy for optimization by networked agents