CodeForces667APouring Rain(数学)

本文介绍了一个有趣的数学问题:在雨中用圆柱形杯子喝水,如何计算在雨水不断补充的情况下能否将杯中的水喝完及所需的时间。文章提供了完整的解析过程和示例代码。
Description
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition — when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do.
Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided to make a formal model of what was happening and to find if it was possible to drink all water in that situation.
Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters from the bottom.

You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of rain to the cup goes evenly and continuously.
Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.
Note one milliliter equals to one cubic centimeter.
Input
The only line of the input contains four integer numbers d, h, v, e (1 ≤ d, h, v, e ≤ 104), where:
d — the diameter of your cylindrical cup,
h — the initial level of water in the cup,
v — the speed of drinking process from the cup in milliliters per second,
e — the growth of water because of rain if you do not drink from the cup.
Output
If it is impossible to make the cup empty, print "NO" (without quotes).
Otherwise print "YES" (without quotes) in the first line. In the second line print a real number — time in seconds needed the cup will be empty. The answer will be considered correct if its relative or absolute error doesn't exceed 10 - 4. It is guaranteed that if the answer exists, it doesn't exceed 104.
Sample Input
Input
1 2 3 100
Output
NO
Input
1 1 1 1
Output
YES
3.659792366325
题意:下雨天拿个杯子去外面喝水(这货有病么……),给你水杯的直径,杯内水的高度,你喝水的速度还有每秒雨水下落到杯内的高度。问你多少秒能喝完水,喝不完的话就输出NO。

思路:简单的计算出杯内水体积再除以每秒喝的体积减去雨下落的体积的差。我是先判断雨落的快还是喝的快,落得快的话直接NO,喝的快再按上述计算。

代码:

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;  
#define pi 3.1415927
int main()
{
	double d,h,v,e;
	while(~scanf("%lf%lf%lf%lf",&d,&h,&v,&e))
	{
		double v1,v2;
		v1=(d/2)*(d/2)*pi*e;
		v2=(d/2)*(d/2)*pi*h;
		if(v1>=v)
		printf("NO\n");
		else
		{
			double time=v2/(v-v1);
			printf("YES\n");
			printf("%lf\n",time);
		}
	}
	return 0;
}


代码下载链接: https://pan.quark.cn/s/6b27a128162e 【关于IAR for Arm 9.20.1的安装指导】 IAR Systems作为业内知名的嵌入式系统开发工具供应商,其推出的IAR Embedded Workbench是一款面向多种微控制器(MCU)的集成开发环境(IDE)。本指导将系统性地阐述安装IAR for ARM 9.20.1版本的具体流程,该版本是专门为基于ARM架构的嵌入式设备量身打造的开发工具。 1. **前期准备** 在启动安装流程之前,务必核实计算机的环境配置符合以下系统要求: - 操作系统版本:Windows 7或更新版本 - 硬盘容量:确保至少有1GB的可用存储空间 - 系统兼容性:支持在32位及64位Windows操作系统上运行 2. **获取与解压缩** 需要从官方网站或者指定的链接获取"IAR For Arm 9.20.1"的压缩文件。文件下载完毕后,借助解压缩软件(例如7-Zip)将内容解压到用户指定的文件夹中。 3. **启动安装流程** 进入解压后的文件夹,找到并执行"IAREmbeddedWorkbenchInstaller.exe"文件,从而启动IAR的安装向导程序。 4. **安装向导界面** - **初始界面**:仔细阅读并同意许可协议条款,随后点击“Next”进入下一阶段。 - **组件选择**:IAR Embedded Workbench通常集成了多个功能模块,包括编译器、调试器接口等。系统默认选中所有模块,用户也可依据实际需求进行个性化选择。本例中采用默认设置,并继续点击“Next”。 - **设定安装位置**:用户可以选择采用系统推荐的安装路径,或者自定义安装位置。确认选择...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值