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. POJ 1941 The Sierpinski Fractal ——模拟

    只需要开一个数组,记录一下这个图形. 通过一番计算,发现最大的面积大约是2k*2k的 然后递归下去染三角形. 需要计算出左上角的坐标. 然后输出的时候需要记录一下每一行最远延伸的地方,防止行末空格过多 ...

  2. BZOJ 4569 [Scoi2016]萌萌哒 ——ST表 并查集

    好题. ST表又叫做稀疏表,这里利用了他的性质. 显然每一个条件可以分成n个条件,显然过不了. 然后发现有许多状态是重复的,首先考虑线段树,没什么卵用. 然后ST表,可以每一层表示对应的区间大小的两个 ...

  3. Java项目性能监控和调优工具-Javamelody的学习总结

    1.简介: JavaMelody能够在运行环境监测Java或Java EE应用程序服务器.并以图表的形式显示:Java内存和Java CPU使用情况,用户Session数量,JDBC连接数,和http ...

  4. Flex布局--必然的选择

    这篇文章是我在阮一峰老师的flex布局教程下,按照自己的理解重写写一遍,以便增强理解.如果你来到这里最好去看一下阮一峰大神的Flex布局教程 正式开始自己的. 说起布局方式,大家首先要了解css3有哪 ...

  5. hdu 1025 n*logn最长上升子序列

    /* TLE */ #include <iostream> #include <cstdio> #include <cstring> using namespace ...

  6. 让python和C/C++联姻【转】

    python不在孤单,轻易而举的为python写C/C++第三方库. 我们都知道python很慢,特别是处理大数据的时候,简直慢到极致,如果在知道代码的瓶颈的时候,可以将需要大量计算的数据块放在C/C ...

  7. 改变querystring值,然后重定向

    原文发布时间为:2009-11-13 -- 来源于本人的百度文章 [由搬家工具导入] 本页面改变querystring值,然后重定向 本页面,避免出现重复querystring。。 如避免出现 www ...

  8. uva 1611:Crane(构造 Grade D)

    题目链接 题意: 一个序列,你可以选择其中偶数长度的一段,然后中间切开,左右两段交换.现给你一个1~n的某个排列,求一个交换方案,使得排列最终有序.(交换次数 < 9^6) 思路: 从左到右,依 ...

  9. php基础 gd图像生成、缩放、logo水印和验证码

    gd库是php最常用的图片处理库之一(另外一个是imagemagick),可以生成图片.验证码.水印.缩略图等等. 图像生成 <?php /* 用windows画图板画图 1.新建空白画布(指定 ...

  10. Codeforces 899 B.Months and Years

    B. Months and Years   time limit per test 1 second memory limit per test 256 megabytes input standar ...