|
Time |
Memory |
Case 1 |
1 sec |
512 MB |
Case 2 |
1 sec |
512 MB |
Case 3 |
1 sec |
512 MB |
Case 4 |
1 sec |
512 MB |
Case 5 |
1 sec |
512 MB |
Case 6 |
1 sec |
512 MB |
Case 7 |
1 sec |
512 MB |
Case 8 |
1 sec |
512 MB |
Description
Koying and Thanksone are enthusiastic students who excel in programming, and are good friends. However, Thanksone likes to play tricks (捉弄) on Koying by hacking his accounts.
To avoid being hacked again, Koying decided to set up a high-strength password, ensuring that Thanksone could never hack him again.
Unfortunately, Thanksone knows Koying very well, and is also very clever. He finally discovered that Koying’s password follows the recursive function below (Koying frequently talks in his sleep and has a pet phrase (口頭禪) “OAO” ^^):

where + represents string concatenation.
Koying’s password is the substring of SN from the L-th position to the R-th position, denoted as SN[L : R].
Now, Thanksone provides you with Koying’s sleep-talking, along with values for N, L, and R. Please determine Koying’s password to assist Thanksone in hacking Koying’s computer.
And when you successfully help Thanksone hack Koying’s computer, Koying’s facial expression will be --> OAO.
Input
The first line contains three positive integers N, L, R.
The second line consists of a string S1, representing Koying's sleep-talking.
It is guaranteed that S1 only contains uppercase English letters.
Constraints
- Test Case 1 : Ensure that S1 is a palindrome,that is S1 = reverse(S1), and N ≤ 10
- Test Case 2 : N ≤ 10
- Test Case 3 : Ensure that S1 is a palindrome,that is S1 = reverse(S1), and N ≤ 50
- Test Cases 4 ~ 5 : N ≤ 50
- Test Cases 6 ~ 8 : satisfy no additional constraints.
- For all test cases : 1 ≤ N ≤ 1015, 1 ≤ L ≤ R ≤ min(|SN|, 1018), |R - L + 1| ≤ min(|SN|, 100), 3 ≤ |S1| ≤ 100
Hints
For Test Cases 3 ~ 5 (and also 1 ~ 2), you may use the following code segment:
//return the k-th character of S_N, that is, S_N[k]
char find(long long int N, long long int k) {
...
}
int main() {
...
for (long long int i = L; i <= R; i++)
printf("%c", find(N, i));
printf("\n");
return 0;
}
Output
Please output a string representing SN[L : R].
Remember to print a ‘\n’ at the end of the output.
Tags