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

Re:其实不用的

Posted by alazyrabbit at 2009-09-02 10:42:58 on Problem 2231
In Reply To:ac了,WA的注意了; Posted by:choupigwb at 2008-11-12 18:00:55
> sort(a,a+n);
> __int64 sum=0;
> for(i=1;i<n;i++)	
>    sum+=(n-i)*(i)*(a[i]-a[i-1]);
> 数组a一定要__int64或者long long, 不然WA;
只需将上面最后一句改为
sum+=(n-i)*(i)*(__int64)(a[i]-a[i-1]);
就可以了,原因自己想一下吧~~

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