forked from bnslakki/Spoj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathASCDFIB.cpp
69 lines (69 loc) · 1.07 KB
/
ASCDFIB.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#define ll int
#define mod 100000
using namespace std;
ll fibo[1100006]; // store fibo no up to 10e6
ll dp[1100006];
ll nth_fib(ll n)
{
if (dp[n] != 0)
return dp[n];
if (n == 1)
return dp[n]=0;
if (n == 2)
return dp[n] = 1;
else
return dp[n] = (nth_fib(n - 1) + nth_fib(n - 2) ) % mod;
}
void pre()
{
for (ll n = 1; n <= 1100004; n++)
{
fibo[n-1] = nth_fib(n);
//printf("%lld\n", nth_fib(n));
}
}
ll cs[100004];
int main()
{
pre();
// freopen("t.txt", "r", stdin);
ll t, k = 0;
scanf("%d", &t);
for (ll j = 1; j <= t; j++)
{
k = 0;
ll a, b;
scanf("%d%d", &a, &b);
for (ll j = 0; j < 100000; j++) cs[j] = 0;
printf("Case %d:", j);
for (ll i = a; i <= a + b; i++)
{
cs[fibo[i-1]]++;
}
int flag = 0;
for (ll i = 0; ; i++)
{
if (cs[i] != 0)
{
for (ll l = 0; l < cs[i]; l++)
{
printf(" %d", i);
k++;
if (k == 100 || k == b + 1)
{
flag = 1;
break;
}
}
}
if (flag == 1)
break;
}
printf("\n");
}
return 0;
}