I would also refer to Bojida Dimitrov's Pentax K-Mount Page and the resolution tests shown there (also quoted by northcoastgreg above):
Measured Resolution Numbers
My conclusion from studying that page is that it is essentially impossible to tell -
in general terms - whether a "K" or an "M" (or "A" for that matter) lens is the better, optically speaking.
My own personal experiences is limited but I do have the 35/3.5 in K version - and it is unbelievably sharp, as the table also indicates. On the other hand, I "only" have the 100/2.8 in M version, and according to the same table the 105/2.8 in K version should have a centre resolution about 40% above that of my humble M-counterpart - but in practice, when comparing my M-pictures with a friend's K-pictures, I cannot tell the difference. They are both excellent performers!
So, my personal conclusion is: If the focal lenght and aperture of any of (the better of) those lenses suit your needs, just buy it whether "K" or "M". (And if you regret, you can almost certainly sell it again without any significant losses).
B. R. / Steen G. B.