Update MCD.cpp

Made query run in constant time.