People are impressed by the seemingly spontaneous origin of genius ideas, but forget all the analytical labor that went into preparing the mind for conceiving such thoughts. Genius doesn't come out of nowhere. The 'stroke of the genius' required a lot of hard work and experience.
And, it works the same with us 'normal' people, even though the results are less spectacular. Want to have a good idea? You need to feed your brain everything you can and obsess over it, then let it stew for a bit. Again, and again. Only then do you stand a chance for a really good idea to just pop out.