Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class dmopc19c1p2 {
- public static StringBuilder f(int N) {
- if (N==0) {
- return new StringBuilder("Good writing is good writing is good writing.");
- } else {
- StringBuilder S = f(N-1);
- StringBuilder newS = new StringBuilder("Good writing is good ")
- .append(S)
- .append(" writing is good ").append(S).append(" is good writing.");
- S = null;
- return newS;
- }
- }
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int q = sc.nextInt();
- for (int i=0; i<q; i++) {
- int n = sc.nextInt();
- int k = sc.nextInt();
- StringBuilder S = f(n);
- if (S.length()<k) {
- System.out.println(".");
- } else {
- System.out.println(S.charAt(k-1));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement