回分類題庫
d180: CP Lab Exercise: Perfect Number
出處:

Difficulity : 1
Accepted : 72 Times | Submit :209 Times | Clicks : 1651
Accepted : 68 Users | Submit : 69 Users | Accepted rate : 99%
Time Limit :10000 ms | Memory Limit : 64000 KBytes
題目加入時間 : 2010-10-20 15:14

Content :

A perfect number N is :
The sum of all the factors of N except N itself is equal to N, we then say N is a perfect number.

For example:
The factors of 6 are 1, 2, 3, 6.
Remove 6 itself we get these factors 1, 2, 3.
The sum of these factors is 6.
=> 6 is a perfect number.

You are asked to write a program to determine if input integers are perfect numbers.

Notice that you have to write a function to determine if a number is a perfect number.

int is_perfect(int);


You have to write function to pass this exercise!!
 

Input :

The first line is a positive number N indicates that there are N numbers need to be tested.
The following N lines are the positive integers we need to test.

Output :

For each test case you need to output one of the following line:
M is a perfect number.
M is not a perfect number.
(M is the input integer)

Sample Input :

2
6
15

Sample Output :

6 is a perfect number.
15 is not a perfect number.

Hint :


  

Author :


  Solve it!   Status Forum (0)

C++
C
JAVA
58684. amy1 (6 ms , 360KB)
85773. alun0922 (8 ms , 356KB)
49486. CC501 (8 ms , 228KB)
25616. cp99703027 (768 ms , 230KB)
39920. mark8211 (794 ms , 218KB)
88415. nccucs105703050 (8 ms , 216KB)
38988. cp100703020 (8 ms , 232KB)
38832. cp100703009 (24 ms , 618KB)
25696. cp99703025 (404 ms , 228KB)
25278. cp99703007 (412 ms , 220KB)
53482. nwgs524513cja (128 ms , 972KB)
50644. nwgs524513cja ( 1.3 s , 1680KB)

執行時間會受很多因素影響因此僅供參考,主機等級請看這裡