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 mickeyandkaka at 2010-11-13 00:00:34 on Problem 1316
可是这程序至少要5秒……


#include <stdio.h>
int fun1(int n)
{
	int s=n;
	while(n>0)
	{
		s+=n%10;
		n/=10;
	}
	return s;
}
int fun2(int n)
{
	int i;
	for(i=1;i<=n;i++)
		if(n==fun1(i)) return 0;
	return 1;
}
int main()
{
	int i;
	for(i=1;i<=9994;i++)
		if(fun2(i))
			printf("%d\n",i);
	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