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 syict05570108 at 2007-08-29 10:29:22 on Problem 1142
#include<math.h>
#include<stdio.h>
int addall;
int add(int n)
{
	int sum=0;
	while(n!=0)
	{
		sum=sum+n%10;
		n=n/10;
	}
	return sum;
}
int prime(int n)
{
	int i,j;
	j=(int)sqrt(n)+1;
	for(i=2;i<j;i++)
	{
		if(n%i==0)
			return 0;
	}
	return 1;
}
int yinzi(int n)
{
	int i=0,j=0,k;
	k=n;
	for(i=2;i<sqrt(k)+1;i++)
	{
		while(k%i==0)
		{
			//	printf("%d ",i);
			n=i;
			addall=addall+add(i);
			k=k/i;	
		}
		
	}
	if(k>n)
	{
		addall=addall+add(k);
	}
	return addall;
}
int main()
{
	int n,i;
	while(scanf("%d",&n))
	{
		if(0==n)
		{
			break;
		}
		for(i=n;;i++)
		{
			if(prime(i))
			{
				continue;
			}
			addall=0;
			if(add(i)==yinzi(i))
			{
				printf("%d\n",i);
				break;
			}
		}
		//printf("%d\n",yinzi(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