标签:http ble 最小 == for view color font 技术分享
http://172.20.6.3/Problem_Show.asp?id=1289
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<algorithm> 5 #include<cmath> 6 #include<queue> 7 using namespace std; 8 int n; 9 int a[10][10]={}; 10 double f[20][10][10][10][10]={}; 11 bool vis[20][10][10][10][10]={}; 12 int main(){ 13 scanf("%d",&n); 14 for(int i=1;i<=8;i++){ 15 for(int j=1;j<=8;j++){ 16 scanf("%d",&a[i][j]); 17 a[i][j]+=a[i][j-1]; 18 a[i][j]+=a[i-1][j]; 19 a[i][j]-=a[i-1][j-1]; 20 } 21 } 22 for(int i=1;i<=8;i++){ 23 for(int j=1;j<=8;j++){ 24 for(int w=i;w<=8;w++){ 25 for(int q=j;q<=8;q++){ 26 f[1][i][j][w][q]=1.0*(a[w][q]-a[i-1][q]-a[w][j-1]+a[i-1][j-1]); 27 f[1][i][j][w][q]*=f[1][i][j][w][q];vis[1][i][j][w][q]=1; 28 } 29 } 30 } 31 } 32 double ro=1.0*a[8][8]/(1.0*n); 33 ro=ro*ro; 34 for(int k=2;k<=n;k++){ 35 for(int i=1;i<=8;i++){ 36 for(int j=1;j<=8;j++){ 37 for(int w=i;w<=8;w++){ 38 for(int q=j;q<=8;q++){ 39 for(int z=i;z<w;z++){ 40 if((vis[k-1][i][j][z][q]&&vis[1][z+1][j][w][q])&&(vis[k][i][j][w][q]==0||f[k][i][j][w][q]-(f[k-1][i][j][z][q]+f[1][z+1][j][w][q])>0)){ 41 f[k][i][j][w][q]=f[k-1][i][j][z][q]+f[1][z+1][j][w][q];vis[k][i][j][w][q]=1; 42 } 43 if((vis[1][i][j][z][q]&&vis[k-1][z+1][j][w][q])&&(vis[k][i][j][w][q]==0||f[k][i][j][w][q]-(f[1][i][j][z][q]+f[k-1][z+1][j][w][q])>0)){ 44 f[k][i][j][w][q]=f[1][i][j][z][q]+f[k-1][z+1][j][w][q];vis[k][i][j][w][q]=1; 45 } 46 } 47 for(int z=j;z<q;z++){ 48 if((vis[k-1][i][j][w][z]&&vis[1][i][z+1][w][q])&&(vis[k][i][j][w][q]==0||f[k][i][j][w][q]-(f[k-1][i][j][w][z]+f[1][i][z+1][w][q])>0)){ 49 f[k][i][j][w][q]=f[k-1][i][j][w][z]+f[1][i][z+1][w][q];vis[k][i][j][w][q]=1; 50 } 51 if((vis[1][i][j][w][z]&&vis[k-1][i][z+1][w][q])&&(vis[k][i][j][w][q]==0||f[k][i][j][w][q]-(f[1][i][j][w][z]+f[k-1][i][z+1][w][q])>0)){ 52 f[k][i][j][w][q]=f[1][i][j][w][z]+f[k-1][i][z+1][w][q];vis[k][i][j][w][q]=1; 53 } 54 } 55 } 56 } 57 } 58 } 59 } 60 double z=f[n][1][1][8][8]/n-ro; 61 z=sqrt(z); 62 printf("%.3f\n",z); 63 return 0; 64 }
NOI1999 JZYZOJ1289 棋盘分割 dp 方差的数学结论
标签:http ble 最小 == for view color font 技术分享
原文地址:http://www.cnblogs.com/137shoebills/p/7786974.html