-
Notifications
You must be signed in to change notification settings - Fork 0
/
fiboString.cpp
51 lines (45 loc) · 880 Bytes
/
fiboString.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
/**
* @file fiboString.cpp
* @author long ([email protected])
* @brief
G(1) = A,
G(2) = B,
G(n) = G(n-2) + G(n-1)
'+': connect two string
find i-th character of n-th fibonacci string
* @version 0.1
* @date 2023-03-22
*
* @copyright Copyright (c) 2023
*
*/
#include<iostream>
#include<vector>
#include<string>
#define MAX 93
using namespace std;
vector<string> fibo_string;
void generating_fibo_string()
{
string str1{"A"}, str2{"B"};
fibo_string.push_back(str1);
fibo_string.push_back(str2);
for(int i=2; i < MAX; i++)
{
string tmp{""};
tmp = fibo_string[i-2] + fibo_string[i-1];
fibo_string.push_back(tmp);
}
}
int main()
{
generating_fibo_string();
int t;
cin >> t;
while(t--)
{
int n, i;
cin >> n >> i;
cout << fibo_string[n-1][i-1] << endl;
}
}