一个整数,除了本身以外的其他所有约数的和如果等于该数,那么我们就称这个整数为完全数。
例如,66 就是一个完全数,因为它的除了本身以外的其他约数的和为 1+2+3=61+2+3=6。
现在,给定你 NN 个整数,请你依次判断这些数是否是完全数。
//
// Created by 24986 on 2022-12-18.
//
#include "iostream"
#include "cstdio"
using namespace std;
int main() {
int n;
cin >> n;
while(n--) {
int x;
cin>>x;
int s=0;
for (int i = 1; i*i <= x; ++i) {
// 判断公约数
if(x%i==0) {
if(i<x) s+=i;
// if(i!=x/i && i!=1) s+=x/i;
if(i!=x/i && x/i<x) s+=x/i;
}
}
if (s==x) printf("%d is perfect\n",x);
else printf("%d is not perfect\n",x);
}
}