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

那个牛人帮我看看哪里错了,总是WRONG.或给点测试数据.

Posted by JNUZL at 2007-09-18 22:36:11 on Problem 3253
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a, const void *b)
{
    return(*(long *)b-*(long *)a);
}
int main()
{int i,n,j;
long a[20010];
__int64 sum=0,t=0;
while(scanf("%d",&n)!=EOF)
{sum=0;t=0;
for(i=0;i<n;i++)
{scanf("%ld",&a[i]);
t=t+a[i];
}
qsort(a,n,sizeof(a[0]),cmp);
sum=sum+t;
for(j=0;j<n-2;j++)
{t=t-a[j];
sum=sum+t;
}
printf("%I64d\n",sum);
}
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