C++ 算法:判断是否存在满足条件的整数对
#include\u0020
int\u0020main()\u0020{ \u0020\u0020int\u0020S, P; \u0020\u0020cin\u0020>>\u0020S\u0020>>\u0020P; \u0020\u0020int\u0020x\u0020=\u0020sqrt(P); \u0020\u0020while\u0020(x\u0020>=\u00201)\u0020{ \u0020\u0020\u0020\u0020int\u0020y\u0020=\u0020P\u0020/\u0020x; \u0020\u0020\u0020\u0020if\u0020(x\u0020*\u0020y\u0020==\u0020P\u0020&&\u00202\u0020*\u0020(x\u0020+\u0020y)\u0020==\u0020S)\u0020{ \u0020\u0020\u0020\u0020\u0020\u0020cout\u0020<<\u0020"Yes"\u0020<<\u0020endl; \u0020\u0020\u0020\u0020\u0020\u0020cout\u0020<<\u0020x\u0020<<\u0020"\u0020"\u0020<<\u0020y\u0020<<\u0020endl; \u0020\u0020\u0020\u0020\u0020\u0020return\u00200; \u0020\u0020\u0020\u0020} \u0020\u0020\u0020\u0020x--; \u0020\u0020} \u0020\u0020cout\u0020<<\u0020"No"\u0020<<\u0020endl; \u0020\u0020return\u00200; }
原文地址: https://www.cveoy.top/t/topic/qfbV 著作权归作者所有。请勿转载和采集!