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 ...
随机推荐
- WCF客户端获取服务端异常[自定义异常]
引言 经过不断的摸索,询问/调试,终于学会了关于WCF客户端与服务端之间异常的处理机制,在此来记录自己的成果,用于记录与分享给需要的伙伴们. 首先感谢[.NET技术群]里群主[轩]的大力帮助,如有需要 ...
- DCDCBigBig's first blog @cnblogs~
其实初二末的时候我就在CSDN上开了博客(主要是为了存模板),但是无奈CSDN的页面真的太辣眼睛了…… 然后我就加入博客园欢快的大家庭啦!!!顺便膜拜巨佬学长%%%(我是蒟蒻不要喷我) 页面设置感谢x ...
- HDU-2222 Keywords Search 字符串问题 AC自动机
题目链接:https://cn.vjudge.net/problem/HDU-2222 题意 给一些关键词,和一个待查询的字符串 问这个字符串里包含多少种关键词 思路 AC自动机模版题咯 注意一般情况 ...
- luogu P1495 曹冲养猪(中国剩余定理)
题意 题解 翻到了一个金句 就跟这句话说得一样,就是个裸题. 所以看模板呗. #include<iostream> #include<cstring> #include< ...
- python 面向对象 封装
什么是封装 广义上的封装:代码的保护,面对对象的思想本身就是 只让自己的对象能调自己类的方法 狭义上的封装:将属性和方法藏起来 私有属性/私有方法 python没有真正意义的私有属性,可以通过调用实例 ...
- Python seed() 函数--每次产生一样的随机数系列
import random random.seed( 10 ) print("Random number with seed 10 : ", random.random()) #0 ...
- USACO 玛丽卡(最短路+枚举)
USACO 玛丽卡 麦克找了个新女朋友,玛丽卡对他非常恼火并伺机报复. 因为她和他们不住在同一个城市,因此她开始准备她的长途旅行. 在这个国家中每两个城市之间最多只有一条路相通,并且我们知道从一个城市 ...
- Python学习简单练习-99乘法表
__author__ = 'ZFH'#-*- coding:utf-8 -*-for i in range(10): #外层循环,range(10),1-9 for j in range(1,i+1) ...
- TreeMap集合怎样依照Value进行排序
------- android培训.java培训.期待与您交流! ---------- 我们知道,TreeMap集合是依照Key进行排序的,怎样依照Value进行排序呢?如今有一个TreeMap集合 ...
- hdoj 1429 胜利大逃亡(续) 【BFS+状态压缩】
题目:pid=1429">hdoj 1429 胜利大逃亡(续) 同样题目: 题意:中文的,自己看 分析:题目是求最少的逃亡时间.确定用BFS 这个题目的难点在于有几个锁对于几把钥匙.唯 ...