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

牛人啊 救命啊~~~5555555

Posted by niuniu2006 at 2008-03-30 10:56:44 on Problem 1387
滑雪过了 然后就加个判断平均值的 结果老wa 哭死了 能帮忙看看行不 我也知道看代码很烦的 哎~

#include <iostream>
using namespace std;

int main()
{while(1){
	int n;double com=-100000000;int sum=0;int c,d;
	int arr[301][301]={0};int brr[301][301]={0};
	/*for(int wo=0;wo<=200;++wo)
		for(int ni=0;ni<=200;++ni)
			brr[wo][ni]=0;*/
	int m;
	cin>>n;if(n==0)
		break;
	cin>>m>>c>>d;
	
	for(int i0=1;i0<=n;++i0)
		for(int j0=1;j0<=m;++j0)
		cin>>arr[i0][j0];
	
	for(int i1=1;i1<=n;++i1)
	{    brr[i1][1]=arr[i1][1];
		for(int j1=1;j1<=m;++j1)
		{
			brr[i1][j1]=brr[i1][j1-1]+arr[i1][j1];
		}
	}
	
	
	for(int i3=1;i3<=n;++i3)
	{
		for(int j3=1;j3<=m;++j3)
		{
			brr[i3][j3]+=brr[i3-1][j3];
		}
	} 
	
	
	int x,y;
	int x1,y1;

	com=brr[1+c-1][1+d-1]-brr[0][d]-brr[c][0]+brr[0][0];
	for(int i2=c;i2<=n;++i2)
	{
		for(int j2=d;j2<=m;++j2)
		{
			
			for(int i=1;i<=n-i2+1;++i)
			{
				for(int j=1;j<=m-j2+1;++j)
				{   
					sum=brr[i+i2-1][j+j2-1]-brr[i-1][j+j2-1]-brr[i+i2-1][j-1]+brr[i-1][j-1];
					
					if(sum/(i2*j2)>com)
					{	com=sum/(i2*j2);x=i;y=j;x1=i2+i-1;y1=j2+j-1;}
					else if(sum/(i2*j2)==com)
					{
						if(x>i)
						{
							x=i;y=j;x1=i2+i-1;y1=j2+j-1;
						}
						else if(x==i)
						{
							if(y>j)
							{
								x=i;y=j;x1=i2+i-1;y1=j2+j-1;
							}
							else if(y==j)
							{
								if(x1>i2+i-1)
								{
									x=i;y=j;x1=i2+i-1;y1=j2+j-1;
								}
								else if(x1==i2+i-1)
								{
									if(y1>j2+j-1)
									{
										x=i;y=j;x1=i2+i-1;y1=j2+j-1;
									}
								}	
							}
								 
						}
					}
				}
			}
		}
	}
	
	cout<<x<<' '<<y<<' '<<x1<<' '<<y1<<endl;
	
}
	cout<<'*'<<endl;
	
	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