[백준 6491] Perfection (C++) - soo:bak
작성일 :
문제 링크
설명
다른 문제 [백준 6975] Deficient, Perfect, and Abundant와 입력 데이터, 출력 형식만 다를 뿐 동일한 문제입니다.
Code
[ C++ ] 
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
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<int> numbers;
  int num;
  while (cin >> num && num != 0)
    numbers.push_back(num);
  for (int num : numbers) {
    cout << num << " ";
    int sum = 0;
    for (int i = 1; i < num; i++) {
      if (num % i == 0) sum += i;
    }
    if (sum < num) cout << "DEFICIENT\n";
    else if (sum == num) cout << "PERFECT\n";
    else cout << "ABUNDANT\n";
  }
  return 0;
}