E
COMP6047 – Algorithm and Programming
T
T
NO
BU
Fibo String
Jojo is learning a series called Fibonacci series where f ib[n] = f ib[n − 1] + f ib[n − 2].
Jojo wondered what if this Fibonacci series was applied to characters, where S[n] =
S[n − 1] + S[n − 2]. For example if Jojo has S[0] = a and S[1] = b then S[2] = ba,
S[3] = bab, S[4] = babba and so on.
RI
O
Format Input T
Inputs start with integer T which is the number of test cases. The next T line contains
D
the integer n, which is the n-th Fibonacci sequence in question followed by two characters
S[0] and S[1]. S[0] and S[1] is guaranteed to be only 1 alphabetical letter.
S
Format Output
DI
The answer begins with the format “Case #X: S[n]” where X is the number of test cases
and S[n] is the n-th order Fibonacci value.
OT
Constraints
UT
RE
• 1 ≤ T ≤ 100
• 1 ≤ n ≤ 15
Sample Input 1 (standard input)
N
3
IB
2 a b
3 a b
4 a b
TR
DO
Sample Output 1 (standard output)
Case #1: ba
Case #2: bab
IS
Case #3: babba
ED
© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.
E
COMP6047 – Algorithm and Programming
T
T
Sample Input 2 (standard input)
NO
BU
3
2 c d
4 a a
2 b b
I
Sample Output 2 (standard output)
R
O
Case #1: dc
Case #2: aaaaa
Case #3: bb
T
D
S
DI
OT
UT
RE
N
IB
TR
DO
IS
ED
© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.
E
COMP6047 – Algorithm and Programming
T
T
NO
BU
Fibo String
Jojo sedang belajar sebuah deret yang disebut dengan deret fibonacci dimana f ib[n] =
f ib[n − 1] + f ib[n − 2]. Jojo penasaran bagaimana jika deret fibonacci ini diterapkan
kepada karakter, dimana S[n] = S[n − 1] + S[n − 2]. Contohnya jika Jojo memiliki
S[0] = a dan S[1] = b maka S[2] = ba, S[3] = bab, S[4] = babba dan seterusnya.
RI
O
Format Input T
Input diawali dengan bilangan bulat T yaitu banyaknya kasus uji. T baris berikutnya
D
berisi integer n, yaitu urutan fibonacci ke-n yang ditanya diikuti dengan dua buah
karakter S[0] dan S[1]. S[0] dan S[1] dijamin hanya berupa 1 buah huruf alfabet.
S
Format Output
DI
Jawaban diawali dengan format “Case #X: S[n]” di mana X adalah jumlah kasus uji
dan S[n] adalah nilai fibonacci urutan ke-n.
OT
Constraints
UT
RE
• 1 ≤ T ≤ 100
• 1 ≤ n ≤ 15
Sample Input 1 (standard input)
N
3
IB
2 a b
3 a b
4 a b
TR
DO
Sample Output 1 (standard output)
Case #1: ba
Case #2: bab
IS
Case #3: babba
ED
© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.
E
COMP6047 – Algorithm and Programming
T
T
Sample Input 2 (standard input)
NO
BU
3
2 c d
4 a a
2 b b
I
Sample Output 2 (standard output)
R
O
Case #1: dc
Case #2: aaaaa
Case #3: bb
T
D
S
DI
OT
UT
RE
N
IB
TR
DO
IS
ED
© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.