E - Cup

The WHU ACM Team has a big cup, with which every member drinks water. Now, we know the volume of the water in the cup, can you tell us it height?

The radius of the cup's top and bottom circle is known, the cup's height is also known.

Input

The input consists of several test cases. The first line of input contains an integer T, indicating the num of test cases.
Each test case is on a single line, and it consists of four floating point numbers: r, R, H, V, representing the bottom radius, the top radius, the height and the volume of the hot water.

Technical Specification

  1. T ≤ 20.
  2. 1 ≤ r, R, H ≤ 100; 0 ≤ V ≤ 1000,000,000.
  3. r ≤ R.
  4. r, R, H, V are separated by ONE whitespace.
  5. There is NO empty line between two neighboring cases.

Output

For each test case, output the height of hot water on a single line. Please round it to six fractional digits.

Sample Input

1
100 100 100 3141562

Sample Output

99.999024

给你水杯的下上半径和高,在给你水的体积,求水高,二分一下就行,注意圆台的公式V=(1/3.0)πh(RR+rr+rR)

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iomanip>
#include<cmath>
#include<float.h> 
#include<string.h>
#include<algorithm>
#define sf scanf
#define pf printf
#define pb push_back
#define mm(x,b) memset((x),(b),sizeof(x))
#include<vector>
#include<map>
#define for(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
typedef long double ld;
typedef double db;
const ll mod=1e12+100;
const db e=exp(1);
using namespace std;
const double pi=acos(-1.0);
db V,r,R,H;
int judge(db mid)
{
    db rr=(R-r)*mid/H+r;
    db v=(1/3.0)*pi*mid*(rr*rr+r*r+rr*r);
    if(v==V) return 0;
    if(v>V) return 1;
    return -1;
}
int main()
{
    int re;
    cin>>re;
    while(re--)
    {
        sf("%lf%lf%lf%lf",&r,&R,&H,&V);
        db right=H,left=0,mid;
        while(right-left>0.00000001)
        {
            mid=(left+right)/2;
            if(judge(mid)==0)
             break;
            else if(judge(mid)>0)
             right=mid;
            else 
            left=mid;
        }
        pf("%.6lf\n",mid);
    }
    return 0;
}

转载于:https://www.cnblogs.com/wzl19981116/p/9382381.html

### SWAT-CUP 安装教程 #### 关于 SWAT-CUP 的安装 SWAT-CUP 是一款用于 SWAT 模型参数敏感性和不确定性分析的软件工具包。其安装过程相对简单,但仍需注意一些细节以确保成功完成配置。 对于 SWAT-CUP 的安装版本选择,通常推荐使用最新稳定版(如 SWAT CUP 2019),因为较新版本修复了许多旧版本中的 bug 并提供了更强大的功能支持[^1]。如果需要兼容特定的操作环境或者已有项目,则可以选择早期版本(如 SWAT CUP 2012)。 以下是关于 SWAT-CUP 安装的一些指导: - **下载地址**: 需要从官方或可信资源网站获取 SWAT-CUP 软件包。例如可以从 Texas A&M University 提供的 SWAT 官方页面或其他授权分发站点下载。 - **系统需求**: 确认计算机满足最低硬件和操作系统要求。Windows 系统是最常见的目标平台,但也存在针对 Linux 和 macOS 的实验性支持方案。 - **依赖项处理**: 在某些情况下可能还需要额外安装其他程序库来保障正常运作,比如 Java Runtime Environment (JRE),这是因为部分图形界面组件基于 Java 技术构建而成。 #### CALIBRATE 按钮不可用的原因分析 当发现 SWAT-CUP 中的 CALIBRATE 功能选项呈现灰化状态而无法激活操作时,这往往提示当前工作流程尚未达到可以启动校正阶段的前提条件。具体原因可归纳如下几点[^2]: - 输入数据未完全加载完毕; - 所选模拟方法不适当或是相关设定不符合逻辑; - 参数范围定义不合理影响后续计算可行性; 因此,在尝试执行任何高级特性之前,请务必仔细核查前期准备工作是否均已妥善安排妥当。 ```python # 示例代码片段展示如何通过命令行调用 SWAT-CUP 进行基本设置验证 import subprocess def check_swatcup_installation(): try: result = subprocess.run(['swatcup', '--version'], capture_output=True, text=True) print(f'SWAT-CUP Version: {result.stdout.strip()}') except FileNotFoundError as e: print('Error: SWAT-CUP is not installed or PATH variable misconfigured.') check_swatcup_installation() ``` 上述脚本可用于初步检测本地机器上是否存在可用的 SWAT-CUP 实例及其大致版本号信息。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值