题目大意:

    给出a, b两个用字符串表示的虚数,求a*b

题目思路:

    偷了个懒,Python3的正则表达式匹配了一下,当然acm里肯定是不行的

 class Solution:
def complexNumberMultiply(self, a, b):
"""
:type a: str
:type b: str
:rtype: str
"""
match = re.search(r'([+-]*\d+)[+-]([+-]*\d+)i$', a)
x1 = int(match.group(1))
y1 = int(match.group(2))
match = re.search(r'([+-]*\d+)[+-]([+-]*\d+)i$', b)
x2 = int(match.group(1))
y2 = int(match.group(2))
ans = ''
ans = ans + str(x1*x2 - y1*y2) + '+'
ans = ans + str(x1*y2 + x2*y1) + 'i'
return ans

537. Complex Number Multiplication的更多相关文章

  1. LC 537. Complex Number Multiplication

    Given two strings representing two complex numbers. You need to return a string representing their m ...

  2. 【LeetCode】537. Complex Number Multiplication 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 解题方法 日期 题目地址:https://leetcode.com/pr ...

  3. 537 Complex Number Multiplication 复数乘法

    详见:https://leetcode.com/problems/complex-number-multiplication/description/ C++: class Solution { pu ...

  4. LeetCode 537. 复数乘法(Complex Number Multiplication)

    537. 复数乘法 537. Complex Number Multiplication 题目描述 Given two strings representing two complex numbers ...

  5. [LeetCode] Complex Number Multiplication 复数相乘

    Given two strings representing two complex numbers. You need to return a string representing their m ...

  6. [Swift]LeetCode537. 复数乘法 | Complex Number Multiplication

    Given two strings representing two complex numbers. You need to return a string representing their m ...

  7. LeetCode Complex Number Multiplication

    原题链接在这里:https://leetcode.com/problems/complex-number-multiplication/description/ 题目: Given two strin ...

  8. [leetcode-537-Complex Number Multiplication]

    Given two strings representing two complex numbers. You need to return a string representing their m ...

  9. ural 1748 The Most Complex Number 和 丑数

    题目:http://acm.timus.ru/problem.aspx?space=1&num=1748 题意:求n范围内约数个数最多的那个数. Roughly speaking, for a ...

随机推荐

  1. 福州大学软件工程1816 | W班 第8次作业[团队作业,随堂小测——校友录]

    作业链接 团队作业,随堂小测--校友录 评分细则 本次个人项目分数由两部分组成(博客分满分40分+程序得分满分60分) 博客和程序得分表 评分统计图 千帆竞发图 总结 旅法师:实现了更新,导出,查询, ...

  2. VMware威睿

    VMware总部位于美国加州帕洛阿尔托 [1]  ,是全球云基础架构和移动商务解决方案厂商,提供基于VMware的解决方案, 企业通过数据中心改造和公有云整合业务,借助企业安全转型维系客户信任 [2- ...

  3. Linux之hosts文件

    一.序言: 今天同事部署环境遇到问题, 原因1:修改了主机名,在/etc/hosts文件中加了3台集群的ip和主机名,但是将默认的前两行也改了,没注意看改了哪里, 现象: 1.zookeeper单台可 ...

  4. Jmeter操作之跨线程组传递参数

    思路:将某一线程组内的变量通过“__setProperty”函数设置成jmeter的全局变量,在另一线程组中通过“__P”函数调用即可. 1.添加-后置处理器-BeanShell PostProces ...

  5. Idea批量修改变量名

    Idea批量修改变量名.在变量名上进行rename操作,所有的同名变量都会自动更改. 快捷键:ALT+SHIFT+R

  6. JavaList addAll removeAll

    List<String>list1=new ArrayList<>(); list1.add("a"); list1.add("b"); ...

  7. 1.Java简介

    第一章 Java简介 开始上传一些自己画的思维导图 画的基本上是根据菜鸟教程Java的对应的图 会有一系列的图陆续放出来,不过博客上只有截图,具体的带注释的具体的图后续会放在git上,更新会加上git ...

  8. logging 实例

    import logging from logging.handlers import RotatingFileHandler import os FILE_DIR = os.path.join(os ...

  9. indexOf刚开始写成IndexOf出错

    {{# if(d.fronturlmin ==null||d.fronturlmin ==""){ }} <img src="@System.Configurati ...

  10. hibernate多对多映射文件的配置

    user.hbm.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate ...