题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1823

1823. Ideal Gas

Time limit: 0.5 second

Memory limit: 64 MB
Many of you know the universal method of solving simple physics problems: you have to find in a textbook an identity in which you know the values of all the quantities except for one, substitute the
numbers into this identity, and calculate the unknown quantity.
This problem is even easier. You know right away that the identity needed for its solution is the Clapeyron–Mendeleev equation for the state of an ideal gas. This equation relates the pressure of an
ideal gas p, the amount of substance n, the volume occupied by the gas V, and the temperature T. Given three of these quantities, you have to find the fourth quantity. Note that the temperature of a gas and the volume occupied
by it must always be positive.

Input

Each of the three input lines has the form “X = value”, where X is the symbol for a physical quantity and value is a nonnegative integer not exceeding 1000. The three lines specify
the values of three different quantities. Pressure is specified in pascals, amount of substance in moles, volume in cubic meters, and temperature in kelvins. It is guaranteed that the temperature and volume are positive. The universal gas constant R should
be taken equal to 8.314 J / (mol · K).

Output

If the input data are inconsistent, output the only line “error”. If the value of X can be determined uniquely, output it in the format “X = value” with an accuracy of 10−3.
If it is impossible to uniquely determine the value of X, output the only line “undefined”.

Sample

input output
p = 1
n = 1
V = 1
T = 0.120279

Notes

Recall that Pa = N / m2 and J = N · m.

PS:

p*V = n*R*T;

代码例如以下:

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const double R = 8.314;
double PP, VV, NN, TT;
void findd(char a, double b)
{
if(a == 'p')
{
PP = b;
}
else if(a == 'V')
{
VV = b;
}
else if(a == 'n')
{
NN = b;
}
else if(a == 'T')
{
TT = b;
}
}
int main()
{ char a;
double b;
while(~scanf("%c = %lf",&a, &b))
{
getchar();
PP = VV = NN = TT = -1;
findd(a,b);
scanf("%c = %lf",&a, &b);
getchar();
findd(a,b);
scanf("%c = %lf",&a, &b);
getchar();
findd(a,b);
if(NN < 0)
{
printf("n = %lf\n",(PP*VV)/(R*TT));
}
else if(PP < 0)
{
printf("p = %lf\n",(NN*R*TT)/(VV));
}
else if(TT < 0 || VV < 0)
{
if(NN==0 && PP==0)
{
printf("undefined\n");
}
else if(NN==0 || PP==0)
{
printf("error\n");
}
else if(TT < 0)
{
printf("T = %lf\n",(PP*VV)/(NN*R));
}
else if(VV < 0)
{
printf("V = %lf\n",(NN*R*TT)/(PP));
}
}
}
return 0;
}

URAL 1823. Ideal Gas(数学啊 )的更多相关文章

  1. URAL 1161 Stripies(数学+贪心)

    Our chemical biologists have invented a new very useful form of life called stripies (in fact, they ...

  2. URAL 2047 Maths (数学)

    对于一个数来说,它的除数是确定的,那么它的前驱也是确定的,而起点只能是1或2,所以只要类似筛法先预处理出每个数的除数个数 ,然后递推出每个数往前的延伸的链长,更新最大长度,记录对应数字.找到maxn以 ...

  3. URAL 1731. Dill(数学啊 )

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1731 1731. Dill Time limit: 0.5 second Memory ...

  4. URAL 1826. Minefield(数学 递归)

    题目链接:http://acm.timus.ru/problem.aspx? space=1&num=1826 1826. Minefield Time limit: 0.5 second M ...

  5. IPv6 tutorial 2 New features: Routing

    https://4sysops.com/archives/ipv6-part-2-new-features-routing/ Routing路由选择 In the last post of my IP ...

  6. SICP-1.4-函数设计

    何为好的函数 每个函数只完成一个工作 不要做重复工作 如果你多次复制一段代码块,说明你应该进行函数抽象了 定义一般化函数 避免特例化 函数说明 一般通过三引号说明 help调出函数说明 避免过多的参数 ...

  7. L180

    The cylinder is a crucial part of the washing machine His debonair dismissal of my inquiry concernin ...

  8. post processing in CFD

    post post Table of Contents 1. Post-processing 1.1. Reverse flow 1.1.1. reasons 1.1.2. solutions 1.2 ...

  9. Usage of hdf2v3 and hdf2file

    备注 修改Filetype,再执行hdf2file或hdf2tab,可以输出不同类型的数据.把Filetype设置成8,就是 Tecplot 格式的数据. <!DOCTYPE html PUBL ...

随机推荐

  1. 成长日记--记录在WB的第一个项目。

    具体为什么跑去外包,只能说自己太水了,或者太懒了,都不好好投简历,也没入这个坑过,如果有想去外包的,除非钱给到市场价的1.5倍以上,否则别考虑了. 项目是国内第一做通信公司的,从具体的需求说起比较好, ...

  2. python基础5(文件操作,with语句)

    打开文件 #使用 open f = open('路径',mode = '打开模式', encoding='编码') #可以使用with语句打开,不需要关闭,可以同时打开多个文件 with open(' ...

  3. React 使用link在url添加参数(url中不可见)

    1. 在要跳转页面添加<Link to={{ pathname: `/staffManagement/cardRecord`, state: {time: YYYY-MM-dd, name: s ...

  4. 浅析为什么 char 类型的范围是 : -128~+127

    在 C 语言中. signed char 类型的范围为 -128~127,每本教科书上也这么写.可是没有哪一本书上(包含老师)也不会给你为什么是 -128~127,这个问题貌似看起来也非常easyea ...

  5. pchip和spline差别

  6. 使用React Hook后的一些体会

    一.前言 距离React Hook发布已经有一段时间了,笔者在之前也一直在等待机会来尝试一下Hook,这个尝试不是像文档中介绍的可以先在已有项目中的小组件和新组件上尝试,而是尝试用Hook的方式构建整 ...

  7. thinkphp5项目--个人博客(四)

    thinkphp5项目--个人博客(四) 项目地址 fry404006308/personalBlog: personalBloghttps://github.com/fry404006308/per ...

  8. Anaconda升级

    Anaconda是可以进行升级的, 这样就省的重装一遍python全家桶了, 比如:   conda update conda conda install anaconda=2018.12   就可以 ...

  9. SFTP的使用

    SFTP的使用: 1.项目中需要引入jar包,下载地址:https://sourceforge.net/projects/jsch/files/jsch.jar/ 2.需要下载SFTP服务器,下载地址 ...

  10. jsp留言板雏形

    编写一个简单的留言簿,实现添加留言和显示留言内容的功能 <%@ page language="java" contentType="text/html; chars ...