Leetcode 537. Complex Number Multiplication
简单模拟题.
class Solution: def complexNumberMultiply(self, a: str, b: str) -> str: a1, a2 = a.split('+') b1, b2 = b.split('+') a1, a2, b1, b2 = map(int, (a1, a2[:-1], b1, b2[:-1])) ans1 = str(a1 * b1 - a2 * b2) ans2 = str(b1 * a2 + a1 * b2) return ans1 + '+' + ans2 + 'i'