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 ...
随机推荐
- matlab Time-domain analysis 渐进式或者实时获取仿真值
首先准备一个传递函数sys, 然后使用lsim(sys,u,t,x0)函数(通用的时序分析的函数) u: The input u is an array having as many rows as ...
- java redistemplate
//添加一个 key ValueOperations<String, Object> value = redisTemplate.opsForValue(); value.set(&quo ...
- GIT配置多用户
在公司工作的时候有时候想提交一点代码到github上,然后一台电脑上就需要配置两个账号分别访问github和公司的gitlab 1. 分别生成两个key 为什么要生成两个key的原因我也不清楚,望路过 ...
- 启动bind时报none:0: open: /etc/named/named.conf: file not found
刚一看,以为是说named.conf文件不存在或权限不够,但仔细查了一下后发现的确在啊,权限改为777也不行.无奈!先查了一下/etc/init.d/named文件里,是在执行/usr/local/n ...
- MongoDB学习笔记<七>
继续MongoDB的学习 1.导出数据(中断其它操作) 把数据库test中的books集合导出 在终端下进行操作 mongoexport -d test -c books -o /home/hadoo ...
- mongodb E11000 duplicate key error collection: index: _id_ dup key
今天在单测的时候,出现这个问题. 我代码只定义了一个变量 let body = {name: 'wu'} 然后连续2次插入这个body数据 await exam.insertExam(body); a ...
- PAT(B) 101-111-1-2014-03-01
1.个位数统计: #include<stdio.h> #include<iostream> #include<string.h> #include<set&g ...
- C# 解压及压缩文件源代码
using System.IO; using System.Windows.Forms; using ICSharpCode.SharpZipLib.Zip; using ICSharpCode.Sh ...
- hdu1864/2844/2159 背包基础题
hdu1864 01背包 题目链接 题目大意:一堆数,找到一个最大的和满足这个和不超过Q要学会分析复杂度! #include <cstdio> #include <cstring&g ...
- plt.rcParams[]
plt.rcParams[] pylot使用rc配置文件来自定义图形的各种默认属性,称之为rc配置或rc参数.通过rc参数可以修改默认的属性,包括窗体大小.每英寸的点数.线条宽度.颜色.样式.坐标轴. ...