题目来源:
比较简单,代码如下:
#include#include #include 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";}