Complex Number Multiply
Python
Medium
3 views
Problem Description
Read a b c d, treat them as complex numbers (a+bi) and (c+di). Multiply them and output real and imag parts.
Input Format
One line: a b c d.
Output Format
One line: real imag.
Constraints
Values fit in 64-bit.
Official Solution
import sys
p=sys.stdin.read().strip().split()
if not p: sys.exit(0)
a=int(p[0]); b=int(p[1]); c=int(p[2]); d=int(p[3])
real=a*c-b*d
imag=a*d+b*c
sys.stdout.write(f'{real} {imag}')
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!