forked from kalmar/DALGLI0
Update 'poly.py'
This commit is contained in:
parent
f76cc9e06d
commit
965b5a0394
31
poly.py
31
poly.py
@ -73,34 +73,3 @@ class Polynomial:
|
||||
if len(p2.coefficients) == 0:
|
||||
return p1
|
||||
return Polynomial.gcd(p2, Polynomial.divide(p1, p2))
|
||||
|
||||
|
||||
def main():
|
||||
Polynomial.n = int(sys.argv[1])
|
||||
c1 = ast.literal_eval(sys.argv[2])
|
||||
c2 = ast.literal_eval(sys.argv[3])
|
||||
|
||||
f = Polynomial(c1)
|
||||
g = Polynomial(c2)
|
||||
|
||||
ans = []
|
||||
|
||||
mul = Polynomial.multiply(f, g)
|
||||
ans.append(mul.coefficients)
|
||||
|
||||
try:
|
||||
div = Polynomial.divide(f, g)
|
||||
ans.append(div.coefficients)
|
||||
except ZeroDivisionError as e:
|
||||
ans.append(e)
|
||||
|
||||
try:
|
||||
gcd = Polynomial.gcd(f, g)
|
||||
ans.append(gcd.coefficients)
|
||||
except ZeroDivisionError as e:
|
||||
ans.append(e)
|
||||
|
||||
print(ans)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user