ZAD4 #33
41
Main.java
41
Main.java
@ -307,6 +307,45 @@ public class Main {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static LinkedList<LinkedList<Integer>> reversible(LinkedList<LinkedList<Integer>> elements,LinkedList<Integer> expect, int mod) {
|
||||
|
||||
LinkedList<LinkedList<Integer>> result = new LinkedList<LinkedList<Integer>>();
|
||||
LinkedList<Integer> temp = new LinkedList<Integer>();
|
||||
|
||||
for(int i=1; i<mod; i++) {
|
||||
result.add(elements.get(i));
|
||||
}
|
||||
|
||||
for(int i=mod; i<elements.size();i++) {
|
||||
|
||||
temp = elements.get(i);
|
||||
|
||||
if(temp.size() <= expect.size()) {
|
||||
temp = nwdPoly(temp, expect, mod);
|
||||
}
|
||||
|
||||
if(temp.size() == 1 && temp.getFirst() == 1) {
|
||||
result.add(elements.get(i));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static LinkedList<Integer> nwdPoly(LinkedList<Integer> p1, LinkedList<Integer> orig, int mod) {
|
||||
|
||||
LinkedList<Integer> temp = new LinkedList<Integer>(p1);
|
||||
|
||||
while(p1.size()>1) {
|
||||
if(p1.size() <= orig.size()) {
|
||||
temp = dividePolynomials(orig,p1,mod);
|
||||
orig = p1;
|
||||
p1 = temp;
|
||||
}
|
||||
|
||||
}
|
||||
return p1;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user