programming-challenges Light, more light (110701) 题解

只是求解该数字是否有平方根即可。

#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <assert.h>
#include <algorithm>
#include <math.h>
#include <ctime>
#include <functional>
#include <string.h>
#include <stdio.h>
#include <numeric>
#include <float.h>

using namespace std;

int main() {
	unsigned u; 
	while (cin >> u) {
		if (u == 0) break;
		unsigned uu = sqrt((double)u);
		if (uu * uu != u) 
			cout << "no" << endl;
		else
			cout << "yes" << endl; 
	}

	return 0; 
}


你可能感兴趣的:(Algorithm,C++)