Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
晕倒! 985Ms过的!有什么好的方法?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator