Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Arrays;
  3.  
  4. public class Main {
  5.  
  6. public static String nukit(int A, int B, int C, int D, boolean check, int turn) {
  7. if (check==false) {
  8. if (turn%2==1) {
  9. return "Roland";
  10. }
  11. else {
  12. return "Patrick";
  13. }
  14. }
  15. else {
  16. int[] a = new int[5];
  17. int[] b = new int[5];
  18. int[] c = new int[5];
  19. int[] d = new int[5];
  20. int[] turns = new int [5];
  21. if (a[0]>=2 && b[0]>=1 && d[0]>=2) {
  22. a[0]-=2;
  23. b[0]-=1;
  24. d[0]-=2;
  25. turns[0]++;
  26. String test = nukit(a[0],b[0],c[0],d[0],check,turns[0]);
  27. if (turns[0]%2==1 && test=="Patrick"){
  28. return "Patrick";
  29. }
  30. else if (turns[0]%2==0 && test=="Roland") {
  31. return "Roland";
  32. }
  33. }
  34. if (a[1]>=1 && b[1]>=1 && c[1]>=1 && d[1]>=1) {
  35. a[1]-=1;
  36. b[1]-=1;
  37. c[1]-=1;
  38. d[1]-=1;
  39. turns[1]++;
  40. String test = nukit(a[1],b[1],c[1],d[1],check,turns[1]);
  41. if (turns[1]%2==1 && test=="Patrick"){
  42. turns[1]++;
  43. return "Patrick";
  44. }
  45. else if (turns[1]%2==0 && test=="Roland") {
  46. turns[1]++;
  47. return "Roland";
  48. }
  49. }
  50. if (c[2]>=2 && d[2]>=1) {
  51. c[2]-=2;
  52. d[2]-=1;
  53. turns[2]++;
  54. String test = nukit(a[2],b[2],c[2],d[2],check,turns[2]);
  55. if (turns[2]%2==1 && test=="Patrick") {
  56. return "Patrick";
  57. }
  58. else if (turns[2]%2==0 && test=="Roland") {
  59. return "Roland";
  60. }
  61. }
  62. if (b[3]>=3) {
  63. b[3]-=3;
  64. turns[3]++;
  65. String test = nukit(a[3],b[3],c[3],d[3],check,turns[3]);
  66. if (turns[3]%2==1 && test=="Patrick"){
  67. return "Patrick";
  68. }
  69. else if (turns[3]%2==0 && test=="Roland") {
  70. return "Roland";
  71. }
  72. }
  73. if (a[4]>=1 && d[4]>=1) {
  74. a[4]-=1;
  75. d[4]-=1;
  76. turns[4]++;
  77. String test = nukit(a[4],b[4],c[4],d[4],check,turns[4]);
  78. if (turns[4]%2==1 && test=="Patrick") {
  79. return "Patrick";
  80. }
  81. else if (turns[4]%2==0 && test=="Roland") {
  82. return "Roland";
  83. }
  84. }
  85. check = false;
  86. turn++;
  87. return nukit(A,B,C,D,check,turn);
  88. }
  89. }
  90.  
  91. public static void main(String[] args) {
  92. Scanner input = new Scanner(System.in);
  93. int num = input.nextInt();
  94. boolean play = true;
  95. int counter = 0, a, b, c, d;
  96. for (int i=0;i<num;i++) {
  97. a = input.nextInt();
  98. b = input.nextInt();
  99. c = input.nextInt();
  100. d = input.nextInt();
  101. System.out.print(nukit(a,b,c,d,play,counter)+"\n");
  102. }
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement