2420 {
2421 unsigned short n;
2422 cin >> n;
2423 unsigned int x;
2424 for(unsigned short i = 0; i < n; i++) {
2425 cin >> x;
2426 unsigned int count = 1;
2427 const auto max = static_cast<unsigned int>(sqrt(static_cast<double>(x)));
2428 for(unsigned int j = 2; j <= max; j++) {
2429 if(x % j == 0) {
2430 count += j;
2431 count += x / j;
2432 if(j == x / j) {
2433 count -= j;
2434 }
2435 }
2436 }
2437 cout << x;
2438 if(x == 1 || count != x) {
2439 cout << " is not perfect";
2440 } else {
2441 cout << " is perfect";
2442 }
2443 cout << endl;
2444 }
2445 return 0;
2446 }