Preparing NOJ

temperature conversions

2000ms 65536K

Description:

John is now madding a calculator that can do Centigrade and Fahrenheit temperature conversions.

In the formulas below, / means to divide, * means to multiply, - means subtract, + means to add and = is equal. Tc = temperature in degrees Centigrade, Tf = temperature in degrees Fahrenheit

To convert a Fahrenheit temperature into Centigrade:

Tc = (5/9)*(Tf-32)

For example, to convert a Fahrenheit temperature of 98.6°F into degrees Centigrade, first subtract 32 from the Fahrenheit temperature to get 66.6. Then you multiply 66.6 by five-ninths to get 37°C.

To convert a Centigrade temperature into degrees Fahrenheit:

Tf = ((9/5)*Tc)+32

For example, to convert a Centigrade temperature of 100 into degrees Fahrenheit, first multiply the Centigrade temperature reading by nine-fifths to get 180. Then add 32 to 180 and get 212°F.


Input:

Line 1 contains an integer T: the number of test cases.

Next T lines, each contains an integer followed by a character ‘C’or ‘F’.


Output:

   For each test case, if ended by ‘C’ it means the number before is Centigrade, and then please convert it to Fahrenheit. Else if ended by ‘F’, convert it to Centigrade. The result should be truncated to integer (1.9 => 1, see it?) in one line. Life is easy, isn’t it?


Sample Input:

2
100C
200F

Sample Output:

212F
93C

Note:

本题由旧版NOJ导入,来源:NUPT ACM 2010 Personal Ranking Contest

Info

NOJ

Provider NOJ

Code NOJ1442

Tags

Submitted 1

Passed 1

AC Rate 100%

Date 04/20/2019 10:03:10

Related

Nothing Yet