import java.util.LinkedList; import java.util.Queue; public class Main { public static void main(String[] args) { String input = args[0]; String[] parts = input.split(" "); // n int mod = Integer.parseInt(parts[0]); //int number = Character.getNumericValue(numberStr.charAt(0)); String polynomialStr = parts[1]; // usuwam '[', ']' polynomialStr = polynomialStr.substring(1, polynomialStr.length()-1); // , String[] polynomialNumbers = polynomialStr.split(","); LinkedList polynomial = new LinkedList(); //test poly LinkedList polynomial2 = new LinkedList(); // wypelnienie wielomianu polynomial = fill(polynomialNumbers, polynomial); //test LinkedList> elements = new LinkedList>(); elements = createCandidates(polynomial,mod); // Idemp System.out.println(idempotent(elements,polynomial,mod)); //showPoly(polynomial); } // wypelnienie wielomianu public static LinkedList fill(String[] str, LinkedList polynomial){ for(int i=0; i poly) { System.out.println(poly.toString()); } public static int multiplier(int number, int expect, int mod) { /* if(nwd(number,mod) != 1 || nwd(number,mod) != number) { System.out.println("NIE DA SIE"); return 0; }*/ for(int i=1;i modPolynomial(int mod, LinkedList polynomial){ LinkedList result = new LinkedList(); while(!polynomial.isEmpty()) { if(polynomial.peek() < 0) { result.add(mod + polynomial.poll()); } else result.add(polynomial.poll() % mod); } return result; } }