poj日记(3299)
来源:互联网 发布:php一键安装环境linux 编辑:程序博客网 时间:2024/06/10 14:25
这几天刚上手刷poj的题,先尝试一些简单题,今天3299
Description
Adapted from Wikipedia, the free encyclopedia
The humidex is a measurement used by Canadian meteorologists to reflect the combined effect of heat and humidity. It differs from the heat index used in the United States in using dew point rather than relative humidity.
When the temperature is 30°C (86°F) and the dew point is 15°C (59°F), the humidex is 34 (note that humidex is a dimensionless number, but that the number indicates an approximate temperature in C). If the temperature remains 30°C and the dew point rises to 25°C (77°F), the humidex rises to 42.3.
The humidex tends to be higher than the U.S. heat index at equal temperature and relative humidity.
The current formula for determining the humidex was developed by J.M. Masterton and F.A. Richardson of Canada's Atmospheric Environment Service in 1979.
According to the Meteorological Service of Canada, a humidex of at least 40 causes "great discomfort" and above 45 is "dangerous." When the humidex hits 54, heat stroke is imminent.
The record humidex in Canada occurred on June 20, 1953, when Windsor, Ontario hit 52.1. (The residents of Windsor would not have known this at the time, since the humidex had yet to be invented.) More recently, the humidex reached 50 on July 14, 1995 in both Windsor and Toronto.
The humidex formula is as follows:
humidex = temperature + hh = (0.5555)× (e - 10.0)e = 6.11 × exp [5417.7530 × ((1/273.16) - (1/(dewpoint+273.16)))]whereexp(x)is 2.718281828 raised to the exponentx.
While humidex is just a number, radio announcers often announce it as if it were the temperature, e.g. "It's 47 degrees out there ... [pause] .. with the humidex,". Sometimes weather reports give the temperature and dewpoint, or the temperature and humidex, but rarely do they report all three measurements. Write a program that, given any two of the measurements, will calculate the third.
You may assume that for all inputs, the temperature, dewpoint, and humidex are all between -100°C and 100°C.
Input
Input will consist of a number of lines. Each line except the last will consist of four items separated by spaces: a letter, a number, a second letter, and a second number. Each letter specifies the meaning of the number that follows it, and will be either T, indicating temperature, D, indicating dewpoint, or H, indicating humidex. The last line of input will consist of the single letter E.
Output
T number D number H numberwhere the three numbers are replaced with the temperature, dewpoint, and humidex. Each value should be expressed rounded to the nearest tenth of a degree, with exactly one digit after the decimal point. All temperatures are in degrees celsius.
Sample Input
T 30 D 15T 30.0 D 25.0E
Sample Output
T 30.0 D 15.0 H 34.0T 30.0 D 25.0 H 42.3
humidex = temperature + h
h = (0.5555)× (e - 10.0)
e = 6.11 × exp [5417.7530 × ((1/273.16) - (1/(dewpoint+273.16)))]
三个公式解出剩下的一个值,然后把三个都输出来.
最后以输入E结束输入.
import java.util.Scanner;public class Poj3299{ public static void main(String[] args) {Scanner scan = new Scanner(System.in);double t = 0.0, d = 0.0, h = 0.0;final double exp = 2.718281828;final double max = 101;int counter = 0;while(!scan.hasNext("E")){ counter = 0; t = max; d = max; h = max; while(true) {if(counter == 2) break;switch(scan.next().toCharArray()[0]){case 'T': t = scan.nextDouble(); break;case 'D': d = scan.nextDouble(); break;case 'H': h = scan.nextDouble(); break;}counter++; } if(h == 101)h = 0.5555 * (6.11 * Math.pow(exp, (5417.7530 * ((1.0 / 273.16) - (1.0 / (d + 273.16))))) - 10.0) + t; else if(t == 101)t = h - 0.5555 * (6.11 * Math.pow(exp, (5417.7530 * ((1.0 / 273.16) - (1.0 / (d + 273.16))))) - 10.0); else d = 1.0 / (1.0 / 273.16 - (Math.log(((h - t) / 0.5555 + 10.0) / 6.11) / 5417.7530)) - 273.16; System.out.printf("T %.1f D %.1f H %.1f \n", t, d, h);} }}
- poj日记(3299)
- poj日记(1001)
- poj日记(1753)
- poj日记(1003)
- poj日记(1004)
- poj日记(1005)
- poj日记(1328)
- poj日记(1222)
- poj日记(3295)
- poj日记(1207)
- poj日记(1936)
- poj日记(1860)
- poj日记(2632)
- poj日记(2965)java
- poj日记(2586)java
- poj日记(1017)——贪心算法
- 汉城日记(一)
- 创业日记(转贴)
- C/C++中static,const,inline三种关键字详细总结
- EJB的home接口
- mac OS开发 线程/定时器/控件隐藏与不使能/关闭窗口与退出app
- SpringMVC+RestFul详细示例实战教程
- 全局异常捕获
- poj日记(3299)
- 计时器
- 休闲食品行业,经销商如何对客户进行管理?
- WPF入门教程系列一——基础
- Spring MongoDB实现LBS功能的其中一种实现
- 解决javax.servlet.jsp.JspException cannot be resolved to a type(JSP页面)
- ubuntu16.04 完整make安装opencv 3.2.0
- iOS 11开发教程(十五)iOS11应用视图的位置和大小
- css简介