Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

算一下对角线就可以了吧?

Posted by sothink at 2004-12-08 19:04:25 on Problem 2101
In Reply To:不能忍了,总WA贴代码上来,大家帮查一下好么?thx Posted by:seol at 2004-12-08 19:01:32
> #include <stdio.h>
> #include <math.h>
> 
> double a[1010][1010];
> int x[1000],y[1000];
> 
> int main()
> {
> 	int n,e,nn,ee,i,j,temp;
> 	double re1,re2,re3,max,mmax;
> 	for (i=0;i<1010;i++) for (j=0;j<1010;j++) a[i][j]=0.0;
> 	scanf("%d%d",&n,&e);
> 	for (nn=0;nn<n-1;nn++) scanf("%d",&x[nn]);
> 	for (ee=0;ee<e-1;ee++) scanf("%d",&y[ee]);
> 	for (nn=n-1;nn>=0;nn--) for (ee=e-1;ee>=0;ee--) {
> 		if (nn==n-1) if (ee==e-1) continue;
> 		if (nn!=n-1) if (ee!=e-1) {
> 			re1=a[nn+1][ee+1]+sqrt(x[nn]*x[nn]+y[nn]*y[nn]);
> 			re2=a[nn+1][ee]+y[nn];
> 			re3=a[nn][ee+1]+x[nn];
> 			max=re1;
> 			if (re2<max) max=re2;
> 			if (re3<max) max=re3;
> 			a[nn][ee]=max;
> 		}
> 		if (nn!=n-1) if (ee==e-1) a[nn][ee]=y[nn]+a[nn+1][ee];
> 		if (nn==n-1) if (ee!=e-1) a[nn][ee]=x[ee]+a[nn][ee+1];
> 	}
> 	mmax=a[0][0];
> 	for (ee=0;ee<=e/2-1;ee++) {temp=y[ee];y[ee]=y[e-2-ee];y[e-2-ee]=temp;}
> 	for (nn=n-1;nn>=0;nn--) for (ee=e-1;ee>=0;ee--) {
> 		if (nn==n-1) if (ee==e-1) continue;
> 		if (nn!=n-1) if (ee!=e-1) {
> 			re1=a[nn+1][ee+1]+sqrt(x[nn]*x[nn]+y[nn]*y[nn]);
> 			re2=a[nn+1][ee]+y[nn];
> 			re3=a[nn][ee+1]+x[nn];
> 			max=re1;
> 			if (re2<max) max=re2;
> 			if (re3<max) max=re3;
> 			a[nn][ee]=max;
> 		}
> 		if (nn!=n-1) if (ee==e-1) a[nn][ee]=y[nn]+a[nn+1][ee];
> 		if (nn==n-1) if (ee!=e-1) a[nn][ee]=x[ee]+a[nn][ee+1];
> 	}
> 	if (a[0][0]>mmax) mmax=a[0][0];
> 	i=0;
> 	while (i<mmax-1e-10) i++;
> 	printf("%d\n",i);
> 	return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator