30,386
社区成员
发帖
与我相关
我的任务
分享
class Solution:
def fib(self, n: int) -> int:
dp = [1] * (n + 1)
dp[0] = 0
for i in range (2, n + 1):
dp[i] = dp[i - 1] + dp[i - 2]
return dp[n]
class Solution:
def complexNumberMultiply(self, num1: str, num2: str) -> str:
real1, imag1 = map(int,num1[:-1].split('+'))
real2, imag2 = map(int,num2[:-1].split('+'))
real3 = real1 * real2 - imag1 * imag2
imag3 = real1 * imag2 + real2 * imag1
return ("{}+{}i").format(real3, imag3)