网站首页 站内搜索

搜索结果

查询Tags标签: multiply,共有 23条记录
  • ABC 235 D - Multiply and Rotate(bfs)

    https://atcoder.jp/contests/abc235/tasks/abc235_d 题目大意: 给定一个数字x作为倍数,给定一个要从1变成的目标数字n。 有两种操作: 第一种是每次都可以*x; 第二种是在当前>10并且最后一位不为0的情况下,把数字的最后一位提前到第一位来形成一个新的数字。问我们…

    2022/9/6 23:24:20 人评论 次浏览
  • 阶乘(n!)的算法

    1 public class DiGui {2 public static void main(String[] args) {3 DiGui diGui = new DiGui();4 System.out.println(diGui.multiply(10));5 public int multiply(int sum){6 if(sum==1){7 return 1;8 }else…

    2022/7/13 1:26:27 人评论 次浏览
  • 【Python入门教程】第61篇 函数进阶之偏函数

    本篇我们介绍偏函数(partial function)的概念,以及如何利用 functools 模块中的 partial 函数定义偏函数。 偏函数的概念 以下示例定义了一个乘法函数,可以将两个参数相乘: def multiply(a, b):return a*b有时候,我们仅仅想要将一个参数和指定的数字(例如 2)相乘。…

    2022/2/23 20:23:51 人评论 次浏览
  • TZOJ 1368:计算球体积 (Java实现)

    我在TZOJ上用简单题目学习Java编程,遇到了这一个题目。 虽然我的编程没有错误,但是总是Wrong answer,以前也遇到这种情况,很可能是计算精度不够导致在保留小数时四舍五入出了问题。 下面贴出代码 import java.math.BigDecimal; import java.math.RoundingMode; import…

    2022/1/24 22:05:43 人评论 次浏览
  • python中doctest文档测试

    doctest doctest为python自带一个测试模块,他会搜索模块中看起来像是交互式会话的代码片段,然后执行并验证结果; 使用方式1: 1、测试用例的位置必须放在整个模块文件的开头,或者紧接着对象声明语句的下一行。也就是可以被 __doc__ 这个属性引用到的地方。并非像普通注…

    2021/12/17 20:22:31 人评论 次浏览
  • python中doctest文档测试

    doctest doctest为python自带一个测试模块,他会搜索模块中看起来像是交互式会话的代码片段,然后执行并验证结果; 使用方式1: 1、测试用例的位置必须放在整个模块文件的开头,或者紧接着对象声明语句的下一行。也就是可以被 __doc__ 这个属性引用到的地方。并非像普通注…

    2021/12/17 20:22:31 人评论 次浏览
  • C - Divide and Multiply

    C - Divide and Multiply 原题链接找不到了...William has array of nn numbers a1​,a2​,…,an​ He can perform the following sequence of operations any number of times:Pick any two items from array ai and aj​, where ai must be a multiple of 2 ai​=ai/2 …

    2021/12/14 23:47:23 人评论 次浏览
  • C - Divide and Multiply

    C - Divide and Multiply 原题链接找不到了...William has array of nn numbers a1​,a2​,…,an​ He can perform the following sequence of operations any number of times:Pick any two items from array ai and aj​, where ai must be a multiple of 2 ai​=ai/2 …

    2021/12/14 23:47:23 人评论 次浏览
  • Python-单元测试,mock类的使用

    官方文档 单元测试: https://docs.python.org/zh-cn/3/library/unittest.html (可做更多研究) mock: https://docs.python.org/zh-cn/3/library/unittest.mock.html?highlight=mock https://docs.python.org/zh-cn/3/library/unittest.mock-examples.html?highlight=…

    2021/10/30 17:42:16 人评论 次浏览
  • Python-单元测试,mock类的使用

    官方文档 单元测试: https://docs.python.org/zh-cn/3/library/unittest.html (可做更多研究) mock: https://docs.python.org/zh-cn/3/library/unittest.mock.html?highlight=mock https://docs.python.org/zh-cn/3/library/unittest.mock-examples.html?highlight=…

    2021/10/30 17:42:16 人评论 次浏览
  • python partial函数

    Python 提供了一个 functools 的模块,该模块为高阶函数提供支持,partial 就是其中的一个函数,该函数的形式如下: functools.partial(func[,*args][, **kwargs])这里先举个例子,看看它是怎么用的。 假设有如下函数: def multiply(x, y): return x * y现在,我们想…

    2021/10/9 12:18:29 人评论 次浏览
  • python partial函数

    Python 提供了一个 functools 的模块,该模块为高阶函数提供支持,partial 就是其中的一个函数,该函数的形式如下: functools.partial(func[,*args][, **kwargs])这里先举个例子,看看它是怎么用的。 假设有如下函数: def multiply(x, y): return x * y现在,我们想…

    2021/10/9 12:18:29 人评论 次浏览
  • Python Fixture——通常用来对测试方法、测试函数、测试类和整个测试文件进行初始化或还原测试环境

    1 #功能函数2 def multiply(a,b):3 return a * b4 5 # ==========fixture==========6 def setup_module(): #模块级:在当前文件中,在所有测试用例执行之前与之后执行7 print("setup_module==========")8 9 def teardown_module…

    2021/9/11 20:06:49 人评论 次浏览
  • Python Fixture——通常用来对测试方法、测试函数、测试类和整个测试文件进行初始化或还原测试环境

    1 #功能函数2 def multiply(a,b):3 return a * b4 5 # ==========fixture==========6 def setup_module(): #模块级:在当前文件中,在所有测试用例执行之前与之后执行7 print("setup_module==========")8 9 def teardown_module…

    2021/9/11 20:06:49 人评论 次浏览
  • python单元测试

    python3直接使用unittest标准库 1. 需要继承unittest.TestCase类 2. 测试方法需要取名为test_xxx()import unittest from unittest import mock from unittest.mock import patchimport UnitTestDemoclass Caculator:def add(self, n1, n2):return n1 + n2def add_and_mul…

    2021/8/25 1:36:01 人评论 次浏览
共23记录«上一页12下一页»
扫一扫关注最新编程教程