Flooded UVA815翻译原题+代码

英语实在是不好,题意都看不懂,背单词又背不下去,那就慢慢翻译吧,反正没事干。

翻译不求用词精准,句子也可能不通顺, 只是能理解了题意就好。

To enable homebuyers to estimate the cost of flood insurance, a real-estate firm provides clients with the elevation of each 10-meter by 10-meter square of land in regions where homes may be purchased.为了确使买房者估测水灾损失,房地产商为顾客提供他们购买土地的每十方平米的海拔。

Water from rain, melting snow, and burst water mains will collect first in those squares with the lowest elevations, since water from squares of higher elevation will run downhill.来自雨水,融雪,爆炸的水会先聚积在海拔最低的地方,因为高地的水会流下来。

For simplicity, we also  assume that 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 will not be absorbed by the land.简单的,我们假设地沟水能够来自高海拔地区山谷(完全被高海拔地区包围)排向低海拔地区,而且谁不会被陆地吸收。
From weather data archives, we know the typical volume of water that collects in a region.从天气档案来看,我们知道典型大量的水聚积与一个地区。
As prospective homebuyers, we wish to know the elevation of the water after it has collected in low-lying squares, and also the percentage of the region's area that is completely submerged (that is, the percentage of 10-meter squares whose elevation is strictly less than the water level).作为一个买房子的人,我们希望知道在低洼地区聚积的水的海拔,和被完全淹没地区的百分比(即,每10米的百分数海拔严格少于水的高度)。
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
double a[100000];
double vol[100000];
int m,n;
double v1,v2;
bool cmp(double aa, double bb)
{
    if(aa>bb) return true;
}

int main()
{
    int kase=0;
    while(scanf("%d%d", &m, &n)!=EOF && !( m==0 && n==0 ) )
    {
        kase++;
        v1=0;
        double temp;
        for(int i=0; i<m*n; i++)
        {
            cin>>temp;
            vol[i] = temp*100;
            v1 += vol[i];
            a[i] = temp;
        }
        sort(a, a+m*n, cmp);
        sort(vol, vol+m*n, cmp);
        cin>>v2;


        double v = v1+v2;
        double height;
        int r = m*n;
        for(int i=0; i<m*n; i++)
        {
            double area=(m*n-i)*100;
            double temp1 = v / area;
            if(temp1 > a[i])
            {
                height = temp1;
                break;
            }
            else
            {
                v = v - a[i]*100;
                r--;
            }
        }
        printf("Region %d\n",kase);
        printf("Water level is %.2lf meters.\n", height);
        printf("%.2f percent of the region is under water.\n\n",(r+0.0)/(m*n)*100);

    }
    return 0;
}





评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值