Resource allocation and dynamic power control for D2D communication underlaying uplink multi-cell networks