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 |
World Finals?为什么我一次A了.#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator