-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path30.cpp
More file actions
32 lines (29 loc) · 666 Bytes
/
30.cpp
File metadata and controls
32 lines (29 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//https://dimikoj.com/problems/30/perfect-number-1-by-dimik-computing
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ios_base::sync_with_stdio (0);
cin.tie (0);
cout.tie (0);
int t;
long long int n, i, sum;
cin >> t;
while (t--) {
sum = 0;
cin >> n;
for (i = 1; i < n; i++) {
if (n % i == 0) {
sum += i;
}
}
if (sum == n) {
cout << "YES, " << n << " is a perfect number!" << "\n";
}
else {
cout << "NO, " << n << " is not a perfect number!" << "\n";
}
}
return 0;
}