Problem 324
Count and Say
Medium · 20 pts · String, Simulation
Problem
The count-and-say sequence starts with '1'. Each next term describes the previous term out loud: read it from left to right, split it into groups of the same digit, and for each group say how many digits there are followed by the digit. For example, '1' is read as 'one 1', giving '11'; '11' is read as 'two 1s', giving '21'; and '21' is read as 'one 2, one 1', giving '1211'. Print the N-th term.
Input
A single integer N.
Output
Print the N-th term of the count-and-say sequence.
Constraints
1 <= N <= 30
Example input
4
Example output
1211
Explanation
Starting from 1, the terms are 1, then 11 (one 1), then 21 (two 1s), then 1211 (one 2, one 1). So the 4th term is 1211.