idemtotent
This commit is contained in:
parent
1b910bbfb4
commit
4fc2ee088c
27
Main.java
27
Main.java
@ -244,5 +244,32 @@ public class Main {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static LinkedList<LinkedList<Integer>> idempotent(LinkedList<LinkedList<Integer>> elements, LinkedList<Integer> expect, int mod) {
|
||||
|
||||
LinkedList<LinkedList<Integer>> result = new LinkedList<LinkedList<Integer>>();
|
||||
LinkedList<Integer> temp = new LinkedList<Integer>();
|
||||
|
||||
result.add(elements.get(0));
|
||||
|
||||
for(int i=1; i<elements.size();i++) {
|
||||
// a*a
|
||||
temp = polynomialsMultiplication(elements.get(i),elements.get(i));
|
||||
|
||||
// mod
|
||||
temp = modPolynomial(mod,temp);
|
||||
|
||||
if(expect.size()<= temp.size()) {
|
||||
temp = dividePolynomials(temp,expect,mod);
|
||||
}
|
||||
|
||||
if(temp.equals(elements.get(i))) {
|
||||
result.add(temp);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user