Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class dmopc19c1p2 {
  3. public static StringBuilder f(int N) {
  4. if (N==0) {
  5. return new StringBuilder("Good writing is good writing is good writing.");
  6. } else {
  7. StringBuilder S = f(N-1);
  8. StringBuilder newS = new StringBuilder("Good writing is good ")
  9. .append(S)
  10. .append(" writing is good ").append(S).append(" is good writing.");
  11. S = null;
  12. return newS;
  13. }
  14. }
  15. public static void main(String[] args) {
  16. Scanner sc = new Scanner(System.in);
  17. int q = sc.nextInt();
  18. for (int i=0; i<q; i++) {
  19. int n = sc.nextInt();
  20. int k = sc.nextInt();
  21. StringBuilder S = f(n);
  22. if (S.length()<k) {
  23. System.out.println(".");
  24. } else {
  25. System.out.println(S.charAt(k-1));
  26. }
  27. }
  28.  
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement