UVa815 Flood flooded!

Source: Internet
Author: User

Description

To enable homebuyers to estimate the cost of flood insurance, a real-estate firm provides clients with the elevation of EA Ch 10-meter by 10-meter Square of the land in regions where homes could be purchased. Water from rain, melting snow, and burst water mains would collect first in those squares with the lowest elevations, since Water from squares of higher elevation would run downhill. For simplicity, we also assume, the storm sewers enable water from high-elevation squares in valleys (completely enclosed By still higher elevation squares) to drain to lower elevation squares, and that water is not being absorbed by the land.


From Weather Data Archives, we know the typical volume of water of this collects in a region. As prospective homebuyers, we wish to know the elevation of the water after it had collected in low-lying squares, and ALS o The percentage of the region's area, which is completely submerged (which is, the percentage of 10-meter squares whose Elev Ation is strictly less than the water level). You is to write the program, that provides these results.

Input the input consists of a sequence of region descriptions. Each begins with a pair of integers, m and n, each less than, giving the dimensions of the rectangular region in 10-meter units. I mmediately following is m lines of n integers giving the elevations of the squares in Row-major Order. Elevations is given in meters, with positive and negative numbers representing elevations above and below sea level, RESP Ectively. The final value in each region description is a integer that indicates the number of cubic meters of water that would coll ECT in the region. A pair of zeroes follows the description of the last region.OutputFor each region, display the region number (1, 2, ...), the water level (in meters above or below sea level) and the P Ercentage of the region's area under water, with a separate line. The water level and percentage of the region's area under water is to being displayed accurate to the fractional digits. Follow the output for each region with a blank line.Sample Input
3 325 37 4551 12 3494 83 27100000 0
Sample Output
Region 1Water, 46.67 meters.66.67 percent of the region is under water.

There is a nxm grid, each of which is a square with a length of 10 meters, and the grid is surrounded by infinitely large walls.
Enter the altitude of each lattice and the total volume of rainwater in the grid.
The elevation of the output water level and the percentage of the area where there is water (i.e. height is strictly less than the horizontal level).

1#include <iostream>2#include <algorithm>3#include <iomanip>4 intMain ()5 {6     using namespacestd;7     intN, M;8     inthai[ -* -];9CIN >> N >>m;Ten      for(inti =0; i < m*n; i++) OneCIN >>Hai[i]; ASort (hai, Hai + m*n);//sorting, arranging the entered altitude from small to large -     intT; -     intK; the     inth; -CIN >>T; -      for(inti =0; i < n*m; i++) -     { +t = t + -*hai[i];//The total flood volume is added to the total volume of the elevation in a single lattice.  -          +K = T/(100.0* (i +1));//T divided by (number of blocks × area) to get average altitude A          at         if(k <= Hai[i +1])//add equal!!!!  -{//k< The elevation of the next lattice, indicating that the flood can only drown into this lattice. -h =i; -              -              Break; -         } in     } -cout <<"water level elevation:"<< k <<Endl; to  +cout <<fixed<< Setprecision (2) << ((H +1)*1.0)/(N*M)) * -<<"% of the area where there is water"<<Endl; -System"Pause"); the     return 0; *  $ Panax Notoginseng}

#include <iomanip.h>

Cout<<setiosflags (ios::fixed) <<setprecision (n);
n is the number of decimal places

UVa815 Flood flooded!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.