Submit | All submissions | Best solutions | Back to list |
CANDS - Count and Say |
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...
1
is read off as "one 1"
or 11
.11
is read off as "two 1s"
or 21
.21
is read off as "one 2
, then one 1"
or 1211
.
Given an integer n, generate the nth sequence. The sequence is 1-indexed, so the first spot is index 1, not 0.
Note: The sequence of integers will be represented as a string.
Input
The first line will contain an integer n indicating the number of test cases to follow. On each line, there will be a test case consisting of an integer.
Output
The count and say version of each test case.
Example
Input: 2
1
4
Output: 1
1211
Added by: | BYU Admin |
Date: | 2015-12-15 |
Time limit: | 1s-3s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 MAWK BC NCSHARP COFFEE DART FORTH GOSU JS-MONKEY JULIA KTLN OCT PROLOG PYPY3 R RACKET SQLITE SWIFT UNLAMBDA |
Resource: | LeetCode |