Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Arrays;
- public class Main {
- public static String nukit(int A, int B, int C, int D, boolean check, int turn) {
- if (check==false) {
- if (turn%2==1) {
- return "Roland";
- }
- else {
- return "Patrick";
- }
- }
- else {
- int[] a = new int[5];
- int[] b = new int[5];
- int[] c = new int[5];
- int[] d = new int[5];
- int[] turns = new int [5];
- if (a[0]>=2 && b[0]>=1 && d[0]>=2) {
- a[0]-=2;
- b[0]-=1;
- d[0]-=2;
- turns[0]++;
- String test = nukit(a[0],b[0],c[0],d[0],check,turns[0]);
- if (turns[0]%2==1 && test=="Patrick"){
- return "Patrick";
- }
- else if (turns[0]%2==0 && test=="Roland") {
- return "Roland";
- }
- }
- if (a[1]>=1 && b[1]>=1 && c[1]>=1 && d[1]>=1) {
- a[1]-=1;
- b[1]-=1;
- c[1]-=1;
- d[1]-=1;
- turns[1]++;
- String test = nukit(a[1],b[1],c[1],d[1],check,turns[1]);
- if (turns[1]%2==1 && test=="Patrick"){
- turns[1]++;
- return "Patrick";
- }
- else if (turns[1]%2==0 && test=="Roland") {
- turns[1]++;
- return "Roland";
- }
- }
- if (c[2]>=2 && d[2]>=1) {
- c[2]-=2;
- d[2]-=1;
- turns[2]++;
- String test = nukit(a[2],b[2],c[2],d[2],check,turns[2]);
- if (turns[2]%2==1 && test=="Patrick") {
- return "Patrick";
- }
- else if (turns[2]%2==0 && test=="Roland") {
- return "Roland";
- }
- }
- if (b[3]>=3) {
- b[3]-=3;
- turns[3]++;
- String test = nukit(a[3],b[3],c[3],d[3],check,turns[3]);
- if (turns[3]%2==1 && test=="Patrick"){
- return "Patrick";
- }
- else if (turns[3]%2==0 && test=="Roland") {
- return "Roland";
- }
- }
- if (a[4]>=1 && d[4]>=1) {
- a[4]-=1;
- d[4]-=1;
- turns[4]++;
- String test = nukit(a[4],b[4],c[4],d[4],check,turns[4]);
- if (turns[4]%2==1 && test=="Patrick") {
- return "Patrick";
- }
- else if (turns[4]%2==0 && test=="Roland") {
- return "Roland";
- }
- }
- check = false;
- turn++;
- return nukit(A,B,C,D,check,turn);
- }
- }
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int num = input.nextInt();
- boolean play = true;
- int counter = 0, a, b, c, d;
- for (int i=0;i<num;i++) {
- a = input.nextInt();
- b = input.nextInt();
- c = input.nextInt();
- d = input.nextInt();
- System.out.print(nukit(a,b,c,d,play,counter)+"\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement