문제 링크입니다: https://www.acmicpc.net/problem/6491
6491번: Perfection
From the article Number Theory in the 1994 Microsoft Encarta: "If a, b, c are integers such that a = bc, a is called a multiple of b or of c, and b or c is called a divisor or factor of a. If c is not 1, b is called a proper divisor of a. Even integers, wh
www.acmicpc.net
long long 자료형
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
void getResult(long long N) | |
{ | |
long long sum = 0; | |
for (long long i = 1; i < N; i++) | |
{ | |
if (N % i == 0) | |
{ | |
sum += i; | |
} | |
} | |
cout << N << " "; | |
if (sum > N) | |
{ | |
cout << "ABUNDANT\n"; | |
} | |
else if (sum == N) | |
{ | |
cout << "PERFECT\n"; | |
} | |
else | |
{ | |
cout << "DEFICIENT\n"; | |
} | |
} | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
while (1) | |
{ | |
long long N; | |
cin >> N; | |
if (N == 0) | |
{ | |
break; | |
} | |
getResult(N); | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 6696번 Too Much Water (0) | 2021.06.03 |
---|---|
백준 6609번 모기곱셈 (0) | 2021.06.03 |
백준 3602번 iChess (0) | 2021.06.03 |
백준 6437번 Golf (2) | 2021.06.01 |
백준 6378번 디지털 루트 (0) | 2021.06.01 |