With the aid of theoretical calculations, a series of molecularly imprinted polymers (MIPs) were designed and prepared for the recognition of dicyandiamide (DCD) via precipitation polymerization using acetonitrile as the solvent at 333 K. On the basis of the long-range correction method of M062X/6-31G(d,p), we simulated the bonding sites, bonding situations, binding energies, imprinted molar ratios, and the mechanisms of interaction between DCD and the functional monomers. Among acrylamide (AM), N, N'-methylenebisacrylamide (MBA), itaconic acid (IA), and methacrylic acid (MAA), MAA was confirmed as the best functional monomer, because the strongest interaction (the maximum number of hydrogen bonds and the lowest binding energy) occurs between DCD and MAA, when the optimal molar ratios for DCD to the functional monomers were used, respectively. Additionally, pentaerythritol triacrylate (PETA) was confirmed to be the best cross-linker among divinylbenzene (DVB), ethylene glycol dimethacrylate (EGDMA), trimethylolpropane trimethylacrylate (TRIM), and PETA. This is due to the facts that the weakest interaction (the highest binding energy) occurs between PETA and DCD, and the strongest interaction (the lowest binding energy) occurs between PETA and MAA. Depending on the results of theoretical calculations, a series of MIPs were prepared. Among them, the ones prepared using DCD, MAA, and PETA as the template, the functional monomer, and the cross-linker, respectively, exhibited the highest adsorption capacity for DCD. The apparent maximum absorption quantity of DCD on the MIP was 17.45 mg/g.