MAIN12A - SelfDescribingSequenceProblem
Everyone loves Swampy. Swampy the Alligator lives under the city and yearns for a more human like existence. Swampy recently learned a new self describing sequence. The sequence is described in blocks where each block has the same number and two consecutive blocks have consecutive numbers in them. To construct the sequence start with '1'. Now '1' means that the following block is of length 1. As '1' was chosen in previous block, therefore '2' is chosen for the current block making the sequence '12'. Now '2' means that the following block is of length 2. As '2' was chosen in previous block, therefore '3' is chosen for the current block making the sequence '1233'. Now '33' means that the following 2 blocks are of length 3. As '3' was chosen in previous block, therefore '4' is chosen for the current block making the sequence '1233444'. And the second '3' in the sequence appends '555' in the already generated sequence, making the sequence '1233444555'.
Input
First line of the input contains an integer T, the number of test cases. Then T test cases follow. Each test case consists of a single integer N.
Output
For each test case, print Case #X: S, where X is the test case number starting from 1, S is the Nth term of the sequence described above.
Example
Input: 4 1 2 3 4 Output: Case #1: 1 Case #2: 2 Case #3: 3 Case #4: 3
Constraints: T <= 10000 1 <= N <= 1000000
hide comments
(^_^):
2013-03-13 11:02:17
too easy accepted on first try |
|
Amrit:
2012-09-28 18:13:54
increasing seq...think of generating...ranges :) |
|
007: Name stolen:
2012-09-07 19:48:32
plz give some more test case
|
|
gabber:
2012-09-02 06:26:48
easy :) |
|
Arun Lakshman:
2012-09-02 05:59:13
Be simple and stupid :) |
|
devu:
2012-06-16 15:48:26
Think normaly!You need to print the whole number! like you need to print 10 not 1 or 0 and in the sequence also dont think it as a string ..........there is no test case which might stuck your answer... just code it and get accepted.
|
|
MR. BEAN :
2012-06-12 19:00:36
100th user to do this problem :) |
|
Sidharth Guglani:
2012-05-27 11:11:57
@BOND thanks , found mistake in my logic |
|
BOND:
2012-05-26 10:05:35
@Sidharth Guglani: no its not |
|
Sidharth Guglani:
2012-05-23 15:56:27
What is output for n=1000000 |
Added by: | Nikunj Jain |
Date: | 2012-03-15 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Vaibhav Mittal |