ASCDFIB - Ascending Fibonacci Numbers
John is trying to learn the Fibonacci sequence. This is what he has learned so far. The first two terms of the sequence are f(1) = 0 and f(2) = 1. The next term f(n) is then calculated by adding the previous two terms f(n-1) and f(n-2). Therefore,
f(1) = 0
f(2) = 1
f(3) = f(2) + f(1) = 1 + 0 = 1
f(4) = f(3) + f(2) = 1 + 1 = 2
f(5) = f(4) + f(3) = 2 + 1 = 3
f(6) = f(5) + f(4) = 3 + 2 = 5
After calculating this for a while, John realized that the values are becoming too big. In order to keep the values small, John changed his algorithm. Instead of calculating f(n) = f(n-1)+f(n-2), he decided he will calculate f(n) = ( f(n-1)+f(n-2) ) % 10^5.
Now John wants to do some research on his new modified Fibonacci sequence. He will give you an integer A (A<=10^5) and an integer B (B<=10^6). You have to output all the terms from f(A) to f(A+B) in ascending order (non-decreasing order). But printing so many numbers is too much of a hassle. So, if there are more than 100 terms in the output, then only print the first 100.
Input
The first line contains an integer T (T<=100), which is the number of test cases.
Each test case contains two positive integers A and B as mentioned before.
Output
For each test case, print case number (Check sample output) and then print the terms from f(A) to f(A+B) in ascending order (non-decreasing order). If there are more than 100 terms in the output, then only print the first 100.
Example
Input: 3 1 3 3 3 100 1 Output: Case 1: 0 1 1 2 Case 2: 1 2 3 5 Case 3: 15075 69026
hide comments
NOVICE:
2014-01-17 14:58:49
give some tricky cases:
|
|
heatOn:
2014-01-04 18:22:30
Sir Please check my submission.It is working correctly on IDEONE but I am getting SIGABRT here |
|
Alok Sharma:
2013-12-28 12:52:31
awesom question lrnd smthing new
|
|
Taym:
2013-12-16 05:16:15
if the input is 1 200 then the first 100 terms are fib(1) , fib(2) .... fib (100) or the smallest 100 terms from fib(1) ... fib(200) after taking the mod ? |
|
Samiul:
2013-09-16 07:48:20
"You have to output all the terms from f(A) to f(A+B) in ascending order (non-decreasing order). But printing so many numbers is too much of a hassle. So, if there are more than 100 terms in the output, then only print the first 100."
|
|
[Lakshman]:
2013-09-16 07:17:16
@Mohammad Samiul Islam Why wrong answer, I am quite sure my solution is correct. PLease check my submission.
|
|
...:
2013-09-14 20:16:17
10046657, Please check my submissions ID. Acc, to me everything is working fine!
|
|
Samiul:
2013-09-14 14:28:51
@c[R]@zY f[R]0G: You made a mistake in your pre() while doing mod. |
|
c[R]@zY f[R]0G:
2013-09-14 12:45:32
I guess my code is fine for all trivial test cases..
|
Added by: | forthright48 |
Date: | 2013-09-13 |
Time limit: | 3s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Editorial |