Logo
(追記) (追記ここまで)

34379번 - Unit Rescue 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB13121292.308%

문제

One day, the Google unit converter disappeared without warning and for no apparent reason. This has thrown the entire campus into chaos, with students being unable to do their homework problems! In this time of crisis, Colorado School of Mines tasked you with creating a new unit converter that can be just as flexible as the Google converter.

Google's unit conversion is so useful in that it can convert from nearly any unit of measure to any other unit of measure, regardless of how esoteric the conversion is. For example, you could convert lightyears to furlongs to millimeters and then to AUs. To make your job easier, the physics department already hastily crafted a table of conversions for you to use in your program, organized as a list of entries consisting of a source unit, a destination unit, and a ratio to convert from the source unit to the destination unit.

There's a catch though: creating every possible conversion of every possible unit would simply take too long, so there may not be a direct conversion from one unit to another using the list given to you. For example, a conversion from picograms to stellar masses will likely not be on the list. However, there may be some chain of other conversions that will allow you to convert between units that do not have a direct conversion. This can even work in reverse when only a "destination to source" conversion is available by simply taking the inverse $\left(\frac{1}{m}\right)$ of the ratio. To continue the example given prior, you could use a chain of metric conversions to convert from picograms to kilograms, a unit that does have a direct conversion to stellar masses.

입력

The first line will contain a single number $n$ $\left(0 < n \leq 10^{6}\right)$. Then the $n$ following lines will contain four elements, separated by spaces:

  1. A lowercase alphabetical word giving the left hand unit of a particular conversion.
  2. A lowercase alphabetical word giving the right hand unit of a particular conversion.
  3. An integer $m$ $\left(0 < m \leq 10^{19}\right)$ giving the numerator of a ratio that can be applied to an amount in order to convert it from the left hand unit to the right hand unit.
  4. An integer $d$ $\left(0 < d \leq 10^{19}\right)$ giving the denominator of a ratio that can be applied to an amount in order to convert it from the left hand unit to the right hand unit.

The input then ends a line containing the following three elements, separated by spaces:

  1. A real number $a$ $\left(0 < a \leq 10^{10}\right)$ giving the amount to be converted. The number contains at most 2ドル$ digits after the decimal point.
  2. A lowercase alphabetical word giving the unit of the input amount (the "source" unit). This unit will exist within the list of conversions given prior.
  3. A lowercase alphabetical word giving the unit to convert to (the "destination" unit). This unit will exist within the list of conversions given prior.

출력

If the conversion can be made, output a single real number that is the amount $a$ converted from the source unit to the destination unit. Answers within 10ドル^{-2}$ will be accepted.

제한

예제 입력 1

3
g kg 1 1000
kg lb 441 200
oz g 567 20
24.0 oz lb

예제 출력 1

1.50

예제 입력 2

6
cm m 1 100
ft cm 762 25
in ft 833334 10000000
ly km 9460730000000 1
ly mi 5878625000000 1
mi in 63360 1
1.73 km m

예제 출력 2

1730.00

예제 입력 3

6
cmph cmps 1 3600
kmph mph 1000 1
miph cmph 5588 125
mph cmph 100 1
miph mph 80467 50
rps rph 3600 1
16913.1 miph mps

예제 출력 3

IMPOSSIBLE

노트

출처

School > CS@Mines > CS@Mines HSPC 2023 > Advanced K번

  • 문제를 만든 사람: Alexander Capehart
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /