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 |
有大哥能帮我看看错在哪里么??#include <stdio.h> #include <math.h> int n,all=0; int chessboard[8][8]={0}; int score[8][8][8][8]={0}; int sum[8][8][8][8][15]={0}; void square(int x1,int y1,int x2,int y2){ int i,j; score[x1][y1][x2][y2]=0; for(i=x1;i<=x2;i++) for(j=y1;j<=y2;j++) score[x1][y1][x2][y2]+=chessboard[i][j]; sum[x1][y1][x2][y2][1]=score[x1][y1][x2][y2]*score[x1][y1][x2][y2]; } void ca_square(){ int i,j,k,l; for(i=0;i<8;i++) for(j=0;j<8;j++) for(k=i;k<8;k++) for(l=j;l<8;l++) square(i,j,k,l); } void ca_sum(){ int i,j,k,l,m,x; int tmp,mi; for(m=2;m<=n;m++) { for(i=0;i<8;i++) for(j=0;j<8;j++) for(k=i;k<8;k++) for(l=j;l<8;l++){ mi=2000000000; for(x=i;x<k;x++){ tmp=score[i][j][x][l]*score[i][j][x][l]+sum[x+1][j][k][l][m-1]; if(tmp<mi) mi=tmp; tmp=sum[i][j][x][l][m-1]+score[x+1][j][k][l]*score[x+1][j][k][l]; if(tmp<mi) mi=tmp; } for(x=j;x<l;x++){ tmp=score[i][j][k][x]*score[i][j][k][x]+sum[i][x+1][k][l][m-1]; if(tmp<mi) mi=tmp; tmp=sum[i][j][k][x][m-1]+score[i][x+1][k][l]*score[i][x+1][k][l]; if(tmp<mi) mi=tmp; } sum[i][j][k][l][m]=mi; } } } int main() { int i,j; scanf("%d",&n); for(i=0;i<8;i++) for(j=0;j<8;j++){ scanf("%d",&chessboard[i][j]); all+=chessboard[i][j]; } ca_square(); ca_sum(); printf("%.3f",sqrt((double)sum[0][0][7][7][n]/(double)n-all*all/(n*n))); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator