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 |
我是按diacuss里面讨论的方法写的,为什么不对...请大牛帮我小查一下...#include "stdio.h" #include "math.h" double a[100000][5]; int main() { int n,i,j; double sum,max,min,MAX; while(scanf("%d",&n)!=EOF) { MAX=0; for(i=0;i<n;i++) { for(j=0;j<5;j++) scanf("%lf",&a[i][j]); } for(double g=0;g<2;g++) { for(double b=0;b<2;b++) for(double c=0;c<2;c++) for(double d=0;d<2;d++) for(double e=0;e<2;e++) { max=-100000;min=100000; for(i=0;i<n;i++) { sum=a[i][0]*pow(-1,g)+a[i][1]*pow(-1,b)+a[i][2]*pow(-1,c)+a[i][3]*pow(-1,d)+a[i][4]*pow(-1,e); if(sum>max) max=sum; if(sum<min) min=sum; } if((max-min)>MAX) MAX=max-min; } } printf("%.2lf\n",MAX); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator