Balanced Ternary
InterviewTime limit1sMemory limit1024 MB
Convert a decimal integer between -10^9 and 10^9 into its unique balanced ternary representation, printing -1 digits as the letter T.
- Level
Medium4 of 10
- Topics
- Math, Implementation, Number theory, String
- Solved
- No attempts yet
Problem
Balanced ternary is a base- numeral system whose digits are , , and .
With it, every integer can be represented in exactly one way without using a separate sign.
Write a program that reads a decimal number and prints it in balanced ternary.
Input
An integer in decimal notation is given.
Output
Print the answer. If a digit is , print 'T' instead.
Constraints
Hint