Hello from the future. I am a time traveller. You would think that in the future we have agreed to use a single scale for measuring temperature. This is not so. In fact, we have all sorts of scales now. All the big brands have made their own. This is a bit confusing. Please help me figure it out. In my day to day work I have to relate to two different scales 𝐴 and 𝐵. Help me find a temperature where the two scales are the same, so I don’t have to worry about it.InputInput consists of two space-separated integers, 𝑋 and 𝑌. 𝑋 is the point on 𝐵 where 𝐴 is zero. 𝑌 is the number of degrees in 𝐵 that equal a change of a single degree in 𝐴.OutputOutput the temperature where both scales are the same. This number must have an absolute or relative error of at most 10−6. If no such temperature exists, output “IMPOSSIBLE” (without the quotes) instead. If more than one such point exists, output “ALL GOOD” (without the quotes) instead.Limits−100≤𝑋≤1001≤𝑌≤100Sample Input 1 Sample Output 132 2-32Sample Input 2 Sample Output 21 3-0.500000000
Question
Hello from the future. I am a time traveller. You would think that in the future we have agreed to use a single scale for measuring temperature. This is not so. In fact, we have all sorts of scales now. All the big brands have made their own. This is a bit confusing. Please help me figure it out. In my day to day work I have to relate to two different scales 𝐴 and 𝐵. Help me find a temperature where the two scales are the same, so I don’t have to worry about it.InputInput consists of two space-separated integers, 𝑋 and 𝑌. 𝑋 is the point on 𝐵 where 𝐴 is zero. 𝑌 is the number of degrees in 𝐵 that equal a change of a single degree in 𝐴.OutputOutput the temperature where both scales are the same. This number must have an absolute or relative error of at most 10−6. If no such temperature exists, output “IMPOSSIBLE” (without the quotes) instead. If more than one such point exists, output “ALL GOOD” (without the quotes) instead.Limits−100≤𝑋≤1001≤𝑌≤100Sample Input 1 Sample Output 132 2-32Sample Input 2 Sample Output 21 3-0.500000000
Solution
To solve this problem, we need to find a temperature where the two scales are the same.
Given that 𝑋 is the point on 𝐵 where 𝐴 is zero and 𝑌 is the number of degrees in 𝐵 that equal a change of a single degree in 𝐴, we can set up an equation to represent this relationship.
Let's denote the temperature where both scales are the same as T.
According to the problem, when the temperature in scale A is T, the temperature in scale B is 𝑋 + 𝑌 * T.
So we have the equation: T = 𝑋 + 𝑌 * T
We can solve this equation for T:
If 𝑌 is not equal to 1, we can rearrange the equation to: T = 𝑋 / (1 - 𝑌)
If 𝑌 is equal to 1 and 𝑋 is not equal to 0, there is no solution, so we output "IMPOSSIBLE".
If 𝑌 is equal to 1 and 𝑋 is equal to 0, there are infinite solutions, so we output "ALL GOOD".
Let's apply this to the sample inputs:
Sample Input 1: 32 2 𝑌 is not equal to 1, so we calculate T = 32 / (1 - 2) = -32 Sample Output 1: -32
Sample Input 2: 1 3 𝑌 is not equal to 1, so we calculate T = 1 / (1 - 3) = -0.5 Sample Output 2: -0.5
Similar Questions
Reading of temperatures is same in which scales like celsius and Kelvin scale 2.celcius and foreignheit scale
Which temperature scale is used by scientists?*1 pointFahrenheitCelsiusKelvin
Describe the three temperature scales used in the laboratory and in everyday life: theFahrenheit scale, the Celsius scale, and the Kelvin scale
Which pair of temperature scales have the same interval step size?*1 pointCelsius and Fahrenheit.Fahrenheit and Kelvin.Kelvin and Celsius.This does not exist.
Fahrenheit to Celsius degreeWrite a Java program to convert temperature from Fahrenheit to Celsius degree.The Fahrenheit scale is a temperature scale based on one proposed in 1724 by physicist Daniel Gabriel Fahrenheit. It uses the degree Fahrenheit (symbol: °F) as the unit.The Celsius scale, previously known as the centigrade scale, is a temperature scale used by the International System of Units (SI). As an SI derived unit, it is used by all countries in the world, except the U.S.Note:One inch is 0.0254 meter.Print upto 1 value after decimal Sample Input:Input a degree in FahrenheitSample Output:Output will have the Celsius degree value of the Fahrenheit degree input valueClick on the image for preview.Constraints:NAExample:Input:212Output:100.00Explanation:-Click on the image for preview.Public Test Cases:# INPUT EXPECTED OUTPUT1 212100.02 300148.9
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.