Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

小菜水过四十题留念。。

Posted by xiaoyaogui at 2011-07-22 17:41:07 on Problem 1528
#include<stdio.h>
int main()
{	
	int i,n,temp,k,sum;
	int a[1000],count=0;
	while(1)
	{
		sum=0;
		scanf("%d",&n);
		if(count==0)
		printf("PERFECTION OUTPUT\n");
		count++;
		k=0;
		if(n==0)
		{
			printf("END OF OUTPUT\n");
			break;
		}
		temp=n/2;
		for(i=2;i<temp;i++)
		{
			if(n%i==0)
				{
					a[k]=i;
					if(i!=n/i)
						a[++k]=n/i;
					k++;
					temp=n/i;
				}
		}
		for(i=0;i<k;i++)
				sum+=a[i];
			if(n!=1) sum=sum+1;
			if(sum==n)
				printf("%5d  PERFECT\n",n);
			if(sum<n)
				printf("%5d  DEFICIENT\n",n);
			if(sum>n)
				printf("%5d  ABUNDANT\n",n);
	}
		return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator