Offline Power Allocation and Spectrum Sensing Strategy in Energy-Harvesting Cognitive Radio Networks