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 waternet at 2005-03-05 23:23:06 on Problem 2231
In Reply To:Re:引起误解了,不好意思 Posted by:ArXoR at 2005-03-05 23:15:00
帮看一下巴 到底哪儿错了阿
#include <stdio.h>
#include <math.h>
int comp(void* a,void *b){
    long *p=(long*)a;
    long *q=(long*)b;
    return *p>*q;
}    
int main(){
    long cow[10000],num,i,j;
    __int64 noise=(__int64)0;
    scanf("%d",&num);   
    for(i=0;i<num;i++){
        scanf("%d",&cow[i]);
    }
    qsort(cow,num,sizeof(long),comp);
    for(i=1;i<num;i++){
        noise=noise+(__int64)2*i*(num-i)*(cow[i]-cow[i-1]);
    }    
    printf("%I64d\n",noise);
    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