1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/复数乘法 [complex-number-multiplication].html
2022-03-29 12:43:11 +08:00

36 lines
1.3 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p><a href="https://baike.baidu.com/item/%E5%A4%8D%E6%95%B0/254365?fr=aladdin" target="_blank">复数</a> 可以用字符串表示,遵循 <code>"<strong>实部</strong>+<strong>虚部</strong>i"</code> 的形式,并满足下述条件:</p>
<ul>
<li><code>实部</code> 是一个整数,取值范围是 <code>[-100, 100]</code></li>
<li><code>虚部</code> 也是一个整数,取值范围是 <code>[-100, 100]</code></li>
<li><code>i<sup>2</sup> == -1</code></li>
</ul>
<p>给你两个字符串表示的复数 <code>num1</code><code>num2</code> ,请你遵循复数表示形式,返回表示它们乘积的字符串。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>num1 = "1+1i", num2 = "1+1i"
<strong>输出:</strong>"0+2i"
<strong>解释:</strong>(1 + i) * (1 + i) = 1 + i2 + 2 * i = 2i ,你需要将它转换为 0+2i 的形式。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>num1 = "1+-1i", num2 = "1+-1i"
<strong>输出:</strong>"0+-2i"
<strong>解释:</strong>(1 - i) * (1 - i) = 1 + i2 - 2 * i = -2i ,你需要将它转换为 0+-2i 的形式。
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>num1</code><code>num2</code> 都是有效的复数表示。</li>
</ul>