ΠΔΠ-14 (2002) - Phase A Junior High School (perfect)

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
C, C++, Java, Pascal, Python

Perfect Numbers

A perfect number is an integer whose factors (excluding itself) sum up to the number itself. For example, perfect numbers are:

  1. 6, because (6 = 1 \times 6) or (2 \times 3), and (1 + 2 + 3 = 6).
  2. 28, because (28 = 1 \times 28), (2 \times 14), or (4 \times 7), and (1 + 2 + 14 + 4 + 7 = 28).

Write a program that takes integers as input and determines whether they are perfect numbers. The number 1 is not considered a perfect number.

Input:

The input file will be named input.txt and will be located in the directory where your program is executed. Each of it's lines will consist of a positive integer that you need to check if it is perfect.

Output:

The output file will be named output.txt and will be located in the directory where your program is executed. Each of it's lines will contain either of the two numbers: 0 or 1.

  • 0: if the number on the corresponding line of the input file is not perfect.
  • 1: if the number on the corresponding line of the input file is perfect.
Examples of Input - Output Files

STDIN (INPUT.TXT)

500
6
15
12
28

STDOUT (OUTPUT.TXT)

0
1
0
0
1
Note:

The executable file to be created should be named perfect.exe.

ATTENTION! You must strictly adhere to the names and structure of the files; otherwise, your answer will be considered incorrect during evaluation.


Comments

There are no comments at the moment.