Perfection


Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1748    Accepted Submission(s): 1051

Problem Description

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/-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." 

Given a number, determine if it is perfect, abundant, or deficient. 

 

Input

A list of N positive integers (none greater than 60,000), with 1 < N < 100. A 0 will mark the end of the list.

 

Output

The first line of output should read PERFECTION OUTPUT. The next N lines of output should list for each input integer whether it is perfect, deficient, or abundant, as shown in the example below. Format counts: the echoed integers should be right justified
within the first 5 spaces of the output line, followed by two blank spaces, followed by the description of the integer. The final line of output should read END OF OUTPUT.

 

Sample Input

15 28 6 56 60000 22 496 0

 

Sample Output

PERFECTION OUTPUT

   15  DEFICIENT

   28  PERFECT

    6  PERFECT

   56  ABUNDANT

60000  ABUNDANT

   22  DEFICIENT

  496  PERFECT

END OF OUTPUT

 

Source

Mid-Atlantic USA 1996

题目大意:假设一个数的约数和大于它,就是ABUNDANT,假设等于它,就是

PERFECT。若果小于它本身,就是DEFICIENT。

思路:按题目要求和规定推断、输出。

#include<stdio.h>

int a[110],b[110];
int main()
{
int i = 0,n;
while(~scanf("%d",&n) && n)
{
a[i] = n;
int sum = 0;
for(int j = 1; j <= n/2; j++)
if(n % j == 0)
sum += j;
if(sum==n)
b[i] = 1;
else if(sum > n)
b[i] = 2;
else if(sum < n)
b[i] = 0;
i++;
}
printf("PERFECTION OUTPUT\n");
for(int j = 0; j < i; j++)
{
printf("%5d ",a[j]);
if(b[j]==2)
printf("ABUNDANT\n");
else if(b[j]==1)
printf("PERFECT\n");
else
printf("DEFICIENT\n");
}
printf("END OF OUTPUT\n");
return 0;
}

HDU1323_Perfection【水题】的更多相关文章

  1. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  2. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  3. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  4. [poj2247] Humble Numbers (DP水题)

    DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...

  5. gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,

    1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人 ...

  6. BZOJ 1303 CQOI2009 中位数图 水题

    1303: [CQOI2009]中位数图 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2340  Solved: 1464[Submit][Statu ...

  7. 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题

    B - 大还是小? Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Description 输入两个实数,判断第一个数大 ...

  8. ACM水题

    ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...

  9. CF451C Predict Outcome of the Game 水题

    Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...

  10. CF451B Sort the Array 水题

    Codeforces Round #258 (Div. 2) Sort the Array B. Sort the Array time limit per test 1 second memory ...

随机推荐

  1. HDU 2896 病毒侵袭(AC自动机水)

    病毒侵袭 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  2. e.keyCode和e.which使用

    1. 不使用jquery获取keyCode var key = 'which' in e ? e.which : e.keyCode;//或者var key = e.which || e.keyCod ...

  3. Reactor模式总结

    Reactor是基于NIO中实现多路复用的一种模式. 什么是Reactor模式 同步的等待多个事件源到达(采用select()实现) 将事件多路分解以及分配相应的事件服务进行处理,这个分派采用serv ...

  4. 简析JVM GC的根搜索算法

    根搜索算法的基本思路是通过一系列的“GC Roots”的对象作为起始点,从这些节点开始往下搜索,搜索的走过的路径称为引用链,当一个对象到“GC Roots”没有引用链可达时(也就是用图论的话说就是从G ...

  5. repeater绑定数组、哈希表、字典 ArrayList/HashTable,Dictionary为datasource

    原文发布时间为:2009-11-19 -- 来源于本人的百度文章 [由搬家工具导入] repeater绑定数组、哈希表、字典datasource为ArrayList/HashTable,Diction ...

  6. 页面get post等查看

    原文发布时间为:2010-03-08 -- 来源于本人的百度文章 [由搬家工具导入] http://www.fiddler2.com/Fiddler2/firstrun.asp

  7. Docker(五):镜像

    一,什么是镜像? Docker的镜像文件是由文件系统叠加而成的.最底端是一个引导文件系统,即bootfs.Docker用户几乎永远没有机会和引导文件有什么交互,实际上,当一个容器启动之后,容器就会被移 ...

  8. yoga安装kali备忘(连接wifi)

    kali 2.0 iso win8 下安装 用 WinSetupFromUSB-1-6-beta2 写入u盘,正常安装系统 启动连接wifi 搜索信号,获取ssid iw wlan0 scan 查看是 ...

  9. [wxPython学习]wx.CallAfter和wx.FutureCall

    [wxPython学习]wx.CallAfter和wx.FutureCall 今天才学到的两个wxPython中的函数:wx.CallAfter和wx.FutureCall.这是两个无关的函数,但又多 ...

  10. Mysql同台机器主从配置

    Mysql主从配置 安装主Mysql 安装前的准备 检查系统是否存在mysql用户 [root@test mysql]# less /etc/passwd | grep mysql mysql:x:5 ...