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 |
越来越多的灵异事件发生了1.用NeverLiving的号提交,32MS,用这个号提交,0MS 2.用NeverLiving的号提交,G++ Ac,C++ Wa,用这个号提交,C++ Ac 3.难道题目的意思是“所有得分的平方的和与平均得分的平方的和的差的算术平方根的最小值”,而不是“所有得分与平均得分的差的平方的和的算术平方根的最小值”? 4.以下程序竟然Ac了 #include <iostream> #include <iomanip> #include <cmath> using namespace std; int map[8][8],s[64][64],N; int yes[64][64][15]; long double dp[64][64][15],want; long double Abs(long double a){if (a>0.0)return a;return -a;} long double t2(long double a){return a*a;} long double f(int u,int v,int h){ int a=u/8,b=u%8,c=v/8,d=v%8; long double t; if (dp[u][v][h]>=0.0)return dp[u][v][h]; if (h==1)return dp[u][v][h]=t2((long double)(s[u][v])); for (int i=a;i<=c && (c-i)*(d-b+1)>=h-1;i++){ t=t2((long double)(s[a*8+b][i*8+d])) +f(i*8+8+b,v,h-1); if (dp[u][v][h]<0.0 || dp[u][v][h]>t){ dp[u][v][h]=t; yes[u][v][h]=i; } } for (int i=c;i>=a && (i-a)*(d-b+1)>=h-1;i--){ t=t2((long double)(s[i*8+b][c*8+d])) +f(a*8+b,i*8-8+d,h-1); if (dp[u][v][h]<0.0 || dp[u][v][h]>t){ dp[u][v][h]=t; yes[u][v][h]=i; } } for (int j=b;j<=d && (d-j)*(c-a+1)>=h-1;j++){ t=t2((long double)(s[a*8+b][c*8+j])) +f(a*8+j+1,v,h-1); if (dp[u][v][h]<0.0 || dp[u][v][h]>t){ dp[u][v][h]=t; yes[u][v][h]=-j-1; } } for (int j=d;j>=b && (j-b)*(c-a+1)>=h-1;j--){ t=t2((long double)(s[a*8+j][c*8+d])) +f(a*8+b,c*8+j-1,h-1); if (dp[u][v][h]<0.0 || dp[u][v][h]>t){ dp[u][v][h]=t; yes[u][v][h]=-j-1; } } return dp[u][v][h]; } int main() { scanf("%d",&N); want=0.0; for (int i=0;i<8;i++)for (int j=0;j<8;j++){ scanf("%d",map[i]+j); want+=(long double)(map[i][j]); } for (int i=0;i<64;i++)for (int j=0;j<64;j++)for (int k=0;k<15;k++)dp[i][j][k]=-1.0; want=want/(long double)(N); for (int i=0;i<8;i++){ for (int j=0;j<8;j++){ s[i*8][i*8+j]=map[i][j]; if (j>0)s[i*8][i*8+j]+=s[i*8][i*8+j-1]; for (int k=1;k<=j;k++)s[i*8+k][i*8+j]=s[i*8][i*8+j]-s[i*8][i*8+k-1]; } if (i>0)for (int j=0;j<8;j++)for (int k=j;k<8;k++) s[j][i*8+k]=s[j][i*8-8+k]+s[i*8+j][i*8+k]; for (int j=1;j<=i;j++)for (int k=0;k<8;k++)for (int l=k;l<8;l++) s[j*8+k][i*8+l]=s[k][i*8+l]-s[k][j*8-8+l]; } cout <<setiosflags(ios::fixed)<<setprecision(3)<<sqrt(f(0,63,N)/(long double)N-want*want)<<endl; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator