SRM 582 Div II Level One: SemiPerfectSquare

题目来源: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";
}


 

 

posted @ 2013-06-23 16:50  爱生活,爱编程  阅读(147)  评论(0)    收藏  举报