题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12580
比较简单,代码如下:
#include <iostream> #include <string> #include <cmath> using namespace std; class SemiPerfectSquare { public: string check(int N); }; string SemiPerfectSquare::check(int N) { int sq = (int)sqrt((double)N); for (int i = 0; i <= sq; i++) { for (int j = 0; j < i; j++) { if (j * i * i == N) { return "Yes"; } } } return "No"; }