| ||||||||||
| 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 | |||||||||
这样都ac,证明没溢出。。a positive integer not greater than 2^32 - 1 inclusive忽悠的吧//要 c++ 提交才行
#include <stdio.h>
#include <algorithm>
#define maxn 250001
int compare(const void * a,const void * b)
{
return *((int*)a)-*((int*)b);
}
int main()
{
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
int a[maxn];
int n,i;
while(scanf("%d",&n)!=EOF){
for(i=0;i<n;i++){
scanf("%d",&a[i]);
if(a[i]<0) printf("error\n");
}
qsort(a,n,sizeof(a[0]),compare);
if(n%2==1) printf("%.1lf\n",(double)a[n/2]);
else {
printf("%.1lf\n",((double)a[n/2]+a[n/2-1])/2);
}
}
return 1;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator