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 |
Re:按多机调度问题贪心做的,谁有测试数据In Reply To:按多机调度问题贪心做的,谁有测试数据 Posted by:xtu1014 at 2010-08-01 15:32:18 > #include<iostream> > #include<cmath> > #define N 40 > using namespace std; > > int A[N],tri[3],n; > > int cmp(const void *x,const void *y){ > return -(*(int *)x-*(int *)y); > } > > int main(){ > int i,j,k,m; > double a,b,c,P; > scanf("%d",&n); > for(i=0;i<n;i++) > scanf("%d",&A[i]); > qsort(A,n,sizeof(int),cmp);//由边值从大到小排序 > memset(tri,0,sizeof(tri)); > j=0; > for(i=0;i<n;i++){//对边值贪心 > tri[j]+=A[i]; > m=tri[j]; > for(k=0;k<3;k++) > if(tri[k]<m){ > m=tri[k]; > j=k; > } > } > if((tri[0]<tri[1]+tri[2])&&(tri[1]<tri[0]+tri[2])&& > (tri[2]<tri[0]+tri[1])){ > a=(double)tri[0]; > b=(double)tri[1]; > c=(double)tri[2]; > P=(a+b+c)/2; > printf("%d\n",(int)(100*sqrt(P*(P-a)*(P-b)*(P-c)))); > } > else > printf("-1\n"); > system("pause"); > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator