The meaning of problems
The first string of "COFFEE", the second string is "CHICKEN", the n-th string from its front 2 and a front connected to each other (i.e., s [n] = s [n -2] + s [n-1], note that s [n-2] in front of s [n-1]), the query Q from the n-th k-th character string of 10 consecutive characters beginning what (if not there are 10 characters but reached the end of the string to stop)
1≤n≤500
1≤k≤min{∣S(n)∣,1012 }. (|S| denotes the length of string s)
answer
Code
#include <bits / STDC ++ H.> the using namespace STD; typedef Long Long LL; const LL + 1e12 inf = 10 ; // K maximum 1e12, coupled to the output 10, the value may inf + 10 1e12 const int MAXN 5e2 + = 10 ; LL S [MAXN]; String ANS1 = " COFFEE " , ANS2 = " CHICKEN " ; char Solve (n-LL, LL K) { IF (n-== . 1 ) return ANS1 [- K- . 1 ]; // array starts from 0, 1 and k from the beginning, so the need -1 the else IF(n-== 2 ) return ANS2 [- K- . 1 ]; IF (K> S [N- 2 ]) return Solve (N- . 1 , KS [N- 2 ]); the else return Solve (N- 2 , K) ; } int main () { / * pretreatment string length * / S [ . 1 ] = . 6 , S [ 2 ] = . 7 ; for ( int I = . 3 ; I <= 500 ; I ++ ) S [I] = S [I- 2] + S [I- . 1 ] <? S INF = [I- 2 ] + S [I- . 1 ]: INF; // if s [i]> 1e12 + 10, the rear have made equal to 1e12 + 10, or overflow int T; CIN >> T; LL n-, K; the while (T-- ) { CIN >> >> n- K; for (I = K LL; I <K + 10 && I <= S [n-]; I ++ ) // a outputs, to the 10 or greater than the total length of the string is stopped (Note that for i longlongs) COUT << Solve (n-, i); COUT << endl; } return 0 ; }