What I would like to know is how in the world did Pakistan and North Korea ever develop nuclear weapons. For Pete’s sake the two countries can barely rub two nickels together.
The ratio of geniuses to idiots is more or less the same in all nations. The trick is in detecting geniuses early, and educating them at their own rate, in their own direction. A dictatorship can easily do that by running innocious IQ tests in schools, as early as possible. Then the smarter children can be transferred into special schools where they have a chance to get the real education, and the parents would praise their Great Leader for the opportunity.
USSR, for example, had a network of "special schools" that were open only to talented children - they had to pass some exams to be admitted. Some of those schools were math-oriented, some did music and arts, some specialized in languages... but in the end their graduates barely needed a university. All that was free, of course.
If you compare that to the current US educational juggernaut, you will see that geniuses here are told to shut up, sit down, and get dumber so that they don't offend their classmates by being brighter. A society that doesn't cultivate their best and brightest isn't going to be very successful in the long run. Even today if you look at names under many published scientific papers you can't fail to notice how many of them are foreign (largely Chinese.)
Finally, it must be said that today the physics of nuclear weapons is pretty well understood. Back in 1940's it was all uncharted territory; nobody knew even if the device will work. It's much easier today to construct a bomb. You still need to do some fine engineering if you are chasing the yield (and NK failed to do that, so far) but the basic explosion is not a rocket science any more.
Rumor has it that the Saudis financed Pakistan.