题目链接: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. Python的那些坑--------括号篇

    在Python中遇见了带不带括号的问题,我目前的是这三种,有问题请指出.如果有其他的,我后续会更新 一  函数带不带括号: def a(x): return x print(a) #不带括号调用的结果 ...

  2. 箭头函数的this

    定义时所处的对象就是它的this 看外层是否有函数 如果有,外层函数的this就是内部箭头函数的this 如果没有,this就是window let obj = { name : '箭头函数', ge ...

  3. redhat下搭建jdk+tomcat环境

    由于redhat自带安装了jdk,我们需要现将其进行卸载 卸载系统自带的jdk版本: 查看自带的jdk: 输入命令:rpm -qa|grep gcj 可能看到如下类似的信息: libgcj-4.1.2 ...

  4. Oracle学习总结(7)—— 常用的数据库索引优化语句总结

    不管是用C/C++/Java等代码编写的程序,还是SQL编写的数据库脚本,都存在一个持续优化的过程.也就是说,代码优化对于程序员来说,是一个永恒的话题. 近期,我们对之前编写的数据库脚本进行了全面的自 ...

  5. python __future__ 的几种特性

    今天看tensorflow的代码,看到python里面有这么几句: from __future__ import absolute_import from __future__ import divi ...

  6. uva live 2326 - Moving Tables

    把房间号映射在一条坐标上,然后排序,最后找从左到右找一次可行的计划,最后找从左到右找一次可行的计划,最后找从左到右找一次可行的计划,最后找从左到右找一次可行的计划, ............ 次数*1 ...

  7. spark的内存分配管理

    SPARK的内存管理器 StaticMemoryManager,UnifiedMemoryManager 1.6以后默认是UnifiedMemoryManager. 这个内存管理器在sparkCont ...

  8. Mono源码学习笔记:Console类(四)

    NullStream 类 (internal class) 以下就是 mcs/class/corlib/System.IO/NullStream.cs: 01: namespace System.IO ...

  9. 可以通过shadowserver来查看开放的mdns(用以反射放大攻击)——中国的在 https://mdns.shadowserver.org/workstation/index.html

    Open mDNS Scanning Project 来自:https://mdns.shadowserver.org/ If you are looking at this page, then m ...

  10. Metasploit的armitage初步使用

      armitage的启动 root@kali:~# armitage 别急,过会儿就好了 .  等扫描完会弹出一个框框然后会多出目标的图标比如目标是打印机