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

晕倒! 985Ms过的!有什么好的方法?

Posted by bailing_0105 at 2008-07-06 12:38:41 on Problem 1423
#include "stdio.h"
#include "stdlib.h"
#include "math.h"

main()
{
	int n,i,j,num;
	unsigned long *m;
	int *r,t;
	double sum = 1;


	scanf("%d",&n);

	m = (unsigned long*)malloc(sizeof(unsigned long)*n);
	r = (int*)malloc(sizeof(int)*n);

	for (i=0; i<n; i++)
	{
		scanf("%d",m+i);
	}


	t=n;
	for (i=1; n>0; i++)
	{
		sum += log10(i);
		
		for (j=0; j<t; j++)
		{
			if (*(m+j) == i)
			{
				*(r+j) = sum;
				n--;
			}
		}
	}
	for (i=0; i<t; i++)
	{
		printf("%d\n",*(r+i));
	}

}

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