ONL
Poman Iteration
- Problem Description
We know about number systems The Roman numerals and the alternative place value system with a given base.
For the purposes of this problem, we limit ourselves to
1) Roman numerals with values up to 3999 (MMMCMXCIX)
2) Place value systerri numbers having bases from 2 (with possible symbols 0, 1) through 36 (with possible symbols 0, 1, ..., 9, A, ... ,Z)
Consider the following procedure:
1) Accept a natural number N (in base 10).
2) If N lies in the closed interval (1,3999), i.e. between 1 and 3999 (both inclusive), convert N to R, its Roman numeral representation; else output N as the result and stop.
3) Identify the base in which the value of R, now considered to be in "place value system", is least and calculate its value in base 10, replacing N with this value.
4) Repeat from step 2
- Constraints
1<=N<=3999.
- Input Format
A single Integer N
- Output
Converted N
- Test Case
lanation​
Answers
Answered by
3
Similar questions