sorry to keep referring to federer here, but out of curiousity...
what does federer need to do in order to keep number 1 until he gets 300 weeks? i believe 299 is safe until shanghai, but what would he need to do in order to keep it for at least one more (big) week?
Anything that does not lose more than 1335 points up to and including Shanghai is enough. So Federer needs a QF in Shanghai to be absolutely certain.
If he does worse than that, it will be sufficient if Djokovic does not win both Beijing and Shanghai. A Shanghai W and Beijing F is "only" 1300 points. Not enough.