• 【2018黑龙江省赛】UPC-7222 Overflow(模拟物理水体积)


    题目描述
    Kayaking is a naughty boy and he loves to play water. One day, Kayaking finds a bucket. The bottom area of the bucket is S and the height is H. Initially, there is V volume water in the bucket. What makes Kayaking happy is that there are N cube woods beside the bucket. The side length of the i-th cube woods is L[i] and its density is P[i]. Kayaking wants to put all the cube woods to the bucket. And then he will put a cover at the top of the bucket. But CoffeeDog doesn’t allow unless Kayaking can tell CoffeeDog the height of the water in the bucket after Kayaking put all the cuboid woods to the bucket. Could you help him?
    It is guaranteed that the cube woods aren’t overlapping. And after putting the wood to the bucket, the bottom of the wood is parallel to the bottom of the bucket.

    输入
    The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
    The first line of each test case contains a single integer N denoting the number of cube woods.
    Then comes N line. Each line has two real numbers L[i] and P[i].
    The last line contains three integers S, H and V.

    输出
    For each test cases, print a single line containing one real number—the height of the water in the bucket(the number should be rounded to the second digit after the decimal point).

    样例输入
    1
    2
    1 1.5
    1 0.5
    5 100 25

    样例输出
    5.30

    提示
    T≤10
    n≤10^4,P≤6,L≤3,H≤100,L≤H
    V,S≤10^7

    题意: 有一个圆柱形容器,给出容器底面积,高,容器内水的体积,再给出n个边长为ai,密度为pi的正方体块,把所有块放入容器中,问最后容器中的水位多高。

    题解: 可以知道,正方体块放入水中,会根据其密度上浮或者下沉,这决定了正方体块没在水中的体积,这个体积即排水体积,进而影响水位高低。首先明确的是几个物理公式,pv=g,即质量=体积*密度,然后是水的密度是1。就可以做这题了。
    我们不关注放进去的过程,什么如果一个个放进去水位会不断抬高,进而一些较大体积的木块会因为水位的抬高而增大浮力,什么水位本身就比一些正方体块低,因此无视密度而只关乎水位的之类的事情都不管,忽略掉,就直接将所有块放入水中。

    然后就会出现,一些密度大于等于水的,完全沉底,那么排水体积直接增加正方体块完整体积。若密度小于水,因为水的密度是1,质量和体积数值上相等,因此排出水的体积即正方体块的完整质量。这样根据质量和体积就求出了完整的排水体积,即水的增加体积,用求和得到的体积除以底面积即可得到水位高度,注意如果水位漫过了容器高度,那么结果就是容器高度

    #include<bits/stdc++.h>///大于等于水密度的直接完全浸没水中
    #define LL long long///否则计算其质量,等于排开水的质量,同时水的密度是1,等于排开水的体积
    #define M(a,b) memset(a,b,sizeof a)///直接计算水增加的体积,最后比较一下是否超过桶高度即可
    #define pb(x) push_back(x)
    using namespace std;
    const int maxn=1008;
    int t,n;
    int main()
    {
        double s,h,v,l,p;
        scanf("%d",&t);
        while(t--)
        {
            scanf("%d",&n);
            double sum=0;
            for(int i=1;i<=n;i++)
            {
                scanf("%lf%lf",&l,&p);
                if(p>=1.0) sum+=l*l*l;
                else sum+=l*l*l*p;
            }
            scanf("%lf%lf%lf",&s,&h,&v);
            sum+=v;
            sum/=s;
            printf("%.2f
    ",sum<h?sum:h);
        }
    }
    
    
  • 相关阅读:
    linux下模拟CISCO设备输出NetFlow数据 规格严格
    国际:十个习惯让你精通新的开发技术
    国人眼中的Scrum
    NetBeans 时事通讯(刊号 # 2 Apr 08, 2008)
    Ruby语言的发展趋势和启示
    离开几天
    Ruby语言的发展趋势和启示
    だ い が く せ い か つ
    NetBeans 时事通讯(刊号 # 2 Apr 08, 2008)
    离开几天
  • 原文地址:https://www.cnblogs.com/kuronekonano/p/11135701.html
Copyright © 2020-2023  润新知