Description

Physics teachers in high school often think that problems given as text are more demanding than pure computations. After all, the pupils have to read and understand the problem first!

So they don't state a problem like ``U=10V, I=5A, P=?" but rather like ``You have an electrical circuit that contains a battery with a voltage of U=10V and a light-bulb. There's an electrical current of I=5A through the bulb. Which
power is generated in the bulb?".

However, half of the pupils just don't pay attention to the text anyway. They just extract from the text what is given: U=10V, I=5A. Then they think: ``Which formulae do I know? Ah yes, P=U*I. Therefore P=10V*5A=500W. Finished."

OK, this doesn't always work, so these pupils are usually not the top scorers in physics tests. But at least this simple algorithm is usually good enough to pass the class. (Sad but true.)

Today we will check if a computer can pass a high school physics test. We will concentrate on the P-U-I type problems first. That means, problems in which two of power, voltage and current are given and the third is wanted.

Your job is to write a program that reads such a text problem and solves it according to the simple algorithm given above.

Input

The first line of the input file will contain the number of test cases.

Each test case will consist of one line containing exactly two data fields and some additional arbitrary words. A data field will be of the form I=xA, U=xV or P=xW, where x is a real number.

Directly before the unit (A, V or W) one of the prefixes m (milli), k (kilo) and M (Mega) may also occur. To summarize it: Data fields adhere to the following grammar:

DataField ::= Concept '=' RealNumber [Prefix] Unit

Concept ::= 'P' | 'U' | 'I'

Prefix ::= 'm' | 'k' | 'M'

Unit ::= 'W' | 'V' | 'A'

Additional assertions:

The equal sign (`=') will never occur in an other context than within a data field.

There is no whitespace (tabs,blanks) inside a data field.

Either P and U, P and I, or U and I will be given.

Output

For each test case, print three lines:

a line saying ``Problem #k" where k is the number of the test case

a line giving the solution (voltage, power or current, dependent on what was given), written without a prefix and with two decimal places as shown in the sample output

a blank line

Sample Input

3
If the voltage is U=200V and the current is I=4.5A, which power is generated?
A light-bulb yields P=100W and the voltage is U=220V. Compute the current, please.
bla bla bla lightning strike I=2A bla bla bla P=2.5MW bla bla voltage?

Sample Output

Problem #1
P=900.00W Problem #2
I=0.45A Problem #3
U=1250000.00V

HINT

#include<stdio.h>
#include<string.h>
int main()
{
int n,t,i,k=1,x;
double P,U,I,b;
char a[1000];
scanf("%d",&n);
getchar();
x=n;
while(n--)
{
P=0;
U=0;
I=0;
gets(a);
t=strlen(a); for(i=0;i<t;i++)
{
b=1;
if(a[i]=='U'&&a[i+1]=='=')
{
i=i+2;
while(a[i]>='0'&&a[i]<='9')
{
U=U*10+a[i]-'0';
i++;
}
if(a[i]=='.')
{
i++;
while(a[i]>='0'&&a[i]<='9')
{
b=b*0.1;
U=U+b*(a[i]-'0');
i++;
}
}
if(a[i]=='m')
{
U=U/1000;
i++;
}
else if(a[i]=='k')
{
U=U*1000;
i++;
}
else if(a[i]=='M')
{
U=U*1000000;
i++;
}
}
else if(a[i]=='P'&&a[i+1]=='=')
{
i=i+2;
while(a[i]>='0'&&a[i]<='9')
{
P=P*10+a[i]-'0';
i++;
}
if(a[i]=='.')
{
i++;
while(a[i]>='0'&&a[i]<='9')
{
b=b*0.1;
P=P+b*(a[i]-'0');
i++;
}
}
if(a[i]=='m')
{
P=P/1000;
i++;
}
else if(a[i]=='k')
{
P=P*1000;
i++;
}
else if(a[i]=='M')
{
P=P*1000000;
i++;
} }
else if(a[i]=='I'&&a[i+1]=='=')
{
i=i+2;
while(a[i]>='0'&&a[i]<='9')
{
I=I*10+a[i]-'0';
i++;
}
if(a[i]=='.')
{
i++;
while(a[i]>='0'&&a[i]<='9')
{
b=b*0.1;
I=I+b*(a[i]-'0');
i++;
}
}
if(a[i]=='m')
{
I=I/1000;
i++;
}
else if(a[i]=='k')
{
I=I*1000;
i++;
}
else if(a[i]=='M')
{
I=I*1000000;
i++;
}
}
}
printf("Problem #%d\n",k);
if(P>0&&I>0)
printf("U=%.2lfV\n",P/I);
else if(P>0&&U>0)
printf("I=%.2lfA\n",P/U);
else if(U>0&&I>0)
printf("P=%.2lfW\n",U*I);
if(k!=x)
printf("\n");
k++;
}
return 0;
}

Problem A: Artificial Intelligence?的更多相关文章

  1. (转) Artificial intelligence, revealed

    Artificial intelligence, revealed Yann LeCunJoaquin Quiñonero Candela It's 8:00 am on a Tuesday morn ...

  2. UVa 537 Artificial Intelligence?

    题目大意:输入一个字符串,根据物理公式P=U*I,已知其中两个量,求第三个量,结果保留两位小数.   Artificial Intelligence?  Physics teachers in hig ...

  3. EECS 649 Introduction to Artificial Intelligence

    EECS 649 Introduction to Artificial IntelligenceExamElectronic Blackboard Submission Due: April 24, ...

  4. (转)A curated list of Artificial Intelligence (AI) courses, books, video lectures and papers

    A curated list of Artificial Intelligence (AI) courses, books, video lectures and papers. Updated 20 ...

  5. ARTIFICIAL INTELLIGENCE FOR GAMES (Ian Millington / John Funge 著)

    相关网站:http://www.ai4g.com PART I AI AND GAMESCHAPTER1 INTRODUCTIONCHAPTER2 GAME AIPART II TECHNIQUESC ...

  6. Artificial intelligence(AI)

    ORM: https://github.com/sunkaixuan/SqlSugar 微软DEMO: https://github.com/Microsoft/BotBuilder 注册KEY:ht ...

  7. Artificial Intelligence Language

    Artificial Intelligence Language Objective We know, a true AI program should have ability to underst ...

  8. 拼写纠正 Artificial Intelligence: A Modern Approach

    Artificial Intelligence: A Modern Approach http://mindhacks.cn/2008/09/21/the-magical-bayesian-metho ...

  9. Artificial Intelligence Research Methodologies 人工智能研究方法

    Computer Science An Overview _J. Glenn Brookshear _11th Edition To appreciate the field of artificia ...

随机推荐

  1. 2016 Multi-University Training Contest 4 总结

    第四场多校队伍的发挥还是相当不错的. 我倒着看题,发觉最后一题树状数组可过,于是跟队友说,便开始写,十分钟AC. 欣君翻译01题给磊哥,发现是KMP裸题,但是发现模板太旧,改改后过了. 11题是一道毒 ...

  2. js获取手机重力感应api

    <html> <head> <title>DeviceOrientationEvent</title> <meta charset="U ...

  3. 奔五的人,准备学习iOS开发

    这些年一直在java/web/android方面折腾,去年最终换成了apple的设备,本想就開始折腾iOS,却始终没能进入状态. 从今天開始,本人宣布:正式进入iOS/xcode 5的编程学习中,也希 ...

  4. 翻转View

    翻转View by 伍雪颖 CGContextRef context = UIGraphicsGetCurrentContext(); [UIView beginAnimations:nil cont ...

  5. 对XXX(数字)安全卫士实在是忍无可忍了,为什么一定要像日本鬼子强奸妇女一样强奸我们这些弱小者

    一直一来对XXX(数字)安全卫士非常痛恨,无耻,恶心,没有底线,还有对待我们这些弱小者,就像当年日本鬼子强奸妇女一样,血粼粼的虐杀我们这些弱小者,无法反抗,又必须接受. 你强制杀掉别人的ADB 就算了 ...

  6. 关于K-Means算法

    在数据挖掘中,K-Means算法是一种cluster analysis的算法,其主要是来计算数据聚集的算法,主要通过不断地取离种子点最近均值的算法. 问题 K-Means算法主要解决的问题如下图所示. ...

  7. s2sh遇到的问题

    一:ids for this class must be manually assigned before calling save() "类名.hbm.xml"映射文件中< ...

  8. linux查看与开启ssh

    首先通过物理终端进入到linux上,手工检查ssh发现没运行/etc/init.d/sshd statussshd is stopped手工启动服务,发现报告权限错误./etc/init.d/sshd ...

  9. Enum基础

    enum ColorE {     RED, GREEN, BLUE; } public class GetEnumContent {     public static void main(Stri ...

  10. yii2.0 从控制器到视图的输出

    在controllers/SiteController.php文件中,添加 public function actionSay($message = 'Hello') { return $this-& ...