2018-06-28 00:24:15 +02:00
|
|
|
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<Integer> polynomial = new LinkedList<Integer>();
|
|
|
|
|
|
|
|
//test poly
|
|
|
|
LinkedList<Integer> polynomial2 = new LinkedList<Integer>();
|
|
|
|
|
|
|
|
// wypelnienie wielomianu
|
|
|
|
polynomial = fill(polynomialNumbers, polynomial);
|
|
|
|
|
|
|
|
//test
|
|
|
|
LinkedList<LinkedList<Integer>> elements = new LinkedList<LinkedList<Integer>>();
|
|
|
|
elements = createCandidates(polynomial,mod);
|
|
|
|
|
|
|
|
// Idemp
|
|
|
|
System.out.println(idempotent(elements,polynomial,mod));
|
|
|
|
|
|
|
|
//showPoly(polynomial);
|
|
|
|
}
|
|
|
|
|
2018-06-28 00:27:52 +02:00
|
|
|
// wypelnienie wielomianu
|
|
|
|
public static LinkedList<Integer> fill(String[] str, LinkedList<Integer> polynomial){
|
|
|
|
|
|
|
|
for(int i=0; i <str.length; i++) {
|
|
|
|
polynomial.add(Integer.parseInt(str[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
return polynomial;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void showPoly(LinkedList<Integer> poly) {
|
|
|
|
System.out.println(poly.toString());
|
|
|
|
}
|
2018-06-28 00:24:15 +02:00
|
|
|
}
|