We point out that the strong CP problem can be resolved by the anthropic principle. The key ideas are to allow explicit breaking(s) of the Peccei-Quinn symmetry which connects the problem to the cosmological constant problem, and to conjecture that the probability distribution of the vacuum energy in the landscape is hierarchical. The axion acquires a large mass from the explicit breaking, and does not contribute to the dark matter abundance. The axion may dominate the energy density of the universe after inflation and reheat the universe by the decay, possibly generating the density perturbations. On the other hand, the axion can be integrated out during inflation, if the explicit breaking is strong enough. All the cosmological problems of the (s)axion with a large Peccei-Quinn scale can be solved.