1
1
forked from kalmar/DALGLI0

Update 'poly.py'

This commit is contained in:
Szymon Wojciechowski 2018-06-27 17:43:04 +00:00
parent f76cc9e06d
commit 965b5a0394

31
poly.py
View File

@ -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()