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

World Finals?为什么我一次A了.

Posted by donkeyinacm at 2010-02-28 21:57:47 on Problem 1877 and last updated at 2010-02-28 21:58:00
#include <iostream>
#include <cmath>
using namespace std;
#define MAXN 35
#define INF 9999999
#define esp 1e-12
int R,C,mCount=1,num;
double h[MAXN][MAXN],v,wl,per,low,high,mid,mv;

double min(double a,double b)
{
	return a<b?a:b;
}

int main()
{
	//freopen("c:/aaa.txt","r",stdin);
	int r,c;
	while(scanf("%d%d",&R,&C)&&(R+C))
	{
		low=INF;
		for(r=0;r<R;r++)
			for(c=0;c<C;c++)
			{
				scanf("%lf",&h[r][c]);
				low=min(low,h[r][c]);
			}
			scanf("%lf",&v);
			high=v/100.0+low;
			while(low+esp<high)
			{
				num=mv=0;
				mid=(low+high)/2.0;
				for(r=0;r<R&&mv+esp<v;r++)
					for(c=0;c<C&&mv+esp<v;c++)
						if(mid>h[r][c]+esp)
						{
							num++;
							mv+=(mid-h[r][c])*100.0;
						}
						if(mv+esp<v)
							low=mid;
						else
							high=mid;
			}
			
			printf("Region %d\n",mCount++);
			printf("Water level is %.2lf meters.\n",mid);
			printf("%.2lf percent of the region is under water.\n\n",double(num)/double(R*C)*100.0);
	}
	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