문제
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, which include 0, are multiples of 2, for example, -4, 0, 2, 10; an odd integer is an integer that is not even, for example, -5, 1, 3, 9. A perfect number is a positive integer that is equal to the sum of all its positive, proper divisors; for example, 6, which equals 1 + 2 + 3, and 28, which equals 1 + 2 + 4 + 7 + 14, are perfect numbers. A positive number that is not perfect is imperfect and is deficient or abundant according to whether the sum of its positive, proper divisors is smaller or larger than the number itself. Thus, 9, with proper divisors 1, 3, is deficient; 12, with proper divisors 1, 2, 3, 4, 6, is abundant."
Problem Statement: Given a number, determine if it is perfect, abundant, or deficient.
입력
A list of N positive integers (none greater than 60,000), with 1 < N < 100. A 0 will mark the end of the list.
출력
The N lines of output should list for each input integer whether it is perfect, deficient, or abundant, as shown in the example below.
풀이
입력받은 각 숫자와
숫자가 가지는 약수들의 합을 비교하는 문제다.
만약 합이 입력받은 수보다 작다면 'DEFICIENT' 같으면 'PERFECT', 클 경우 'ABUNDANT'를 출력하면 된다.
그런데 틀렸다.
찾아보니 입력이 한 줄로 들어온다는 보장이 없다.
https://www.acmicpc.net/board/view/54969
input을 한 줄 입력(readline) 대신 전체 입력(read)으로 변경해주자.
소스코드
출처
'PS > Baekjoon Online Judge' 카테고리의 다른 글
[백준 02193] 이진수 [Python] (0) | 2024.08.06 |
---|---|
[백준 06784] Multiple Choice [Python] (0) | 2024.08.06 |
[백준 30958] 서울사이버대학을 다니고 [Python] (0) | 2024.07.28 |
[백준 06438] Reverse Text [Python] (0) | 2024.07.26 |
[백준 11727] 2×n 타일링 2 [Python] (0) | 2024.07.26 |