URAL 1823. Ideal Gas(数学啊 )
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1823
1823. Ideal Gas
Memory limit: 64 MB
numbers into this identity, and calculate the unknown quantity.
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
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 it is impossible to uniquely determine the value of X, output the only line “undefined”.
Sample
| input | output |
|---|---|
p = 1 |
T = 0.120279 |
Notes
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(数学啊 )的更多相关文章
- URAL 1161 Stripies(数学+贪心)
Our chemical biologists have invented a new very useful form of life called stripies (in fact, they ...
- URAL 2047 Maths (数学)
对于一个数来说,它的除数是确定的,那么它的前驱也是确定的,而起点只能是1或2,所以只要类似筛法先预处理出每个数的除数个数 ,然后递推出每个数往前的延伸的链长,更新最大长度,记录对应数字.找到maxn以 ...
- URAL 1731. Dill(数学啊 )
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1731 1731. Dill Time limit: 0.5 second Memory ...
- URAL 1826. Minefield(数学 递归)
题目链接:http://acm.timus.ru/problem.aspx? space=1&num=1826 1826. Minefield Time limit: 0.5 second M ...
- IPv6 tutorial 2 New features: Routing
https://4sysops.com/archives/ipv6-part-2-new-features-routing/ Routing路由选择 In the last post of my IP ...
- SICP-1.4-函数设计
何为好的函数 每个函数只完成一个工作 不要做重复工作 如果你多次复制一段代码块,说明你应该进行函数抽象了 定义一般化函数 避免特例化 函数说明 一般通过三引号说明 help调出函数说明 避免过多的参数 ...
- L180
The cylinder is a crucial part of the washing machine His debonair dismissal of my inquiry concernin ...
- 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 ...
- Usage of hdf2v3 and hdf2file
备注 修改Filetype,再执行hdf2file或hdf2tab,可以输出不同类型的数据.把Filetype设置成8,就是 Tecplot 格式的数据. <!DOCTYPE html PUBL ...
随机推荐
- Hadoop_MapReduce中Mapper类和Reduce类
在权威指南中,有个关于处理温度的MapReduce类,具体如下: 第一部分:Map public class MaxTemperatureMapper extends MapReduceBase im ...
- [洛谷P3939]数颜色
题目大意:有n个物品,每个物品有一个颜色.现在有两种操作:1.查询l-r内有多少颜色为c的物品并输出.2.将第x个物品和第x+1个交换.现在让你实现这些操作. 解题思路:首先一共有300000种颜色, ...
- JVM内存管理简单剖析
Java是一个跨平台语言,屏蔽操作系统的差异,无需关心复杂内存管理,做到编写一次到处运行.其强大的能力源于Java Virtual Machine (虚拟机)默默的付出.代码运行在虚拟机之上,虚拟机运 ...
- vue-quill-editor-upload : 实现vue-quill-editor上传图片到服务器
vue-quill-editor-upload git: https://github.com/NextBoy/vu... A plug-in for uploading images to your ...
- 改造vue-quill-editor: 结合element-ui上传图片到服务器
前排提示:现在可以直接使用封装好的插件vue-quill-editor-upload 需求概述 vue-quill-editor是我们再使用vue框架的时候常用的一个富文本编辑器,在进行富文本编辑的时 ...
- 【codeforces 816A】Karen and Morning
[题目链接]:http://codeforces.com/contest/816/problem/A [题意] 让你一分钟一分钟地累加时间; 问多长时间以后是个回文串; [题解] reverse之后如 ...
- Leetcode--easy系列9
#198 House Robber You are a professional robber planning to rob houses along a street. Each house ha ...
- hdu4405--Aeroplane chess(概率dp第七弹:飞行棋游戏--2012年网络赛)
Aeroplane chess Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- IIC总线协议基础1
文档类别 文档标识 IIC总线协议基础1 当前版本号 V0.2 作 者 Louis 完毕时间 2015-05-27 IIC总线协议基础1 IIC总线协议基础1. 1. II ...
- 转发真阿当老师的一片文章 受益匪浅 (出处:http://cly84920.blog.163.com/blog/static/24750013320158203575958/)
忽悠程序员做一辈子程序员,以白胡子白头发hacker为目标的人有两种: 1,自己不写程序,但需要有将才为自己打下手的人,这种人往往看他资质和勤奋均平平,却成了你领导.别不服,这种人虽不见得有帅才的能力 ...