Cognitive radio is a promising technology for increasing the system capacity by using the radio spectrum more effectively. It has been widely studied recently and one important problem in this new paradigm is the allocation of radio spectrum to secondary users effectively in the presence of primary users. We call it the cognitive radio spectrum allocation problem (CRSAP) in this paper. In the conventional problem formulation, a secondary user can be either on or off and its interference range becomes maximum or zero, respectively. We first develop a solution to CRSAP based on the newly proposed chemical reaction-inspired metaheuristic called Chemical Reaction Optimization (CRO). We study different utility functions, accounting for utilization and fairness, with the consideration of the hardware constraint, and compare the performance of our proposed CRO-based algorithm with existing ones. Simulation results show that the CRO-based algorithm always outperforms the others dramatically. Next, by allowing adjustable transmission power, we propose power-controlled CRSAP (PC-CRSAP), a new formulation to the problem with the consideration of spatial diversity. We design a two-phase algorithm to solve PC-CRSAP, and again simulation results show excellent performance.