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 quzhaojing at 2010-07-18 17:53:46 on Problem 2231
In Reply To:秀代码的又来了 Posted by:zjut020 at 2008-11-22 22:23:05
> #include<iostream>
> #include<string>
> #include<fstream>
> #include<iomanip>
> 
> using namespace std;
> int main()
> {
>    //ifstream cin("0000.txt");
>    int n,aa[10000];
>    cin>>n;
>    for(int i=0;i<n;i++)
>    cin>>aa[i];
>    sort(aa,aa+n);
>    unsigned long long sum=0,temp;
>    for(int i=n-2;i>=0;i--)
>    {temp=(aa[i+1]-aa[i]);
>        sum+=temp*(n-i-1)*(i+1);        
>    }
>    cout<<sum*2<<endl;
>    //system("pause");
>    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