问题:求区间[a, b]内所有整数的最大公倍数 方法:利用公式:lcm(a, b) = |a*b|/gcd(a, b) 代码如下: ...
分类:
其他好文 时间:
2016-12-10 18:46:21
阅读次数:
157
1 def LCM(m, n): 2 3 if m*n == 0: 4 return 0 5 if m > n: 6 lcm = m 7 else: 8 lcm = n 9 10 while lcm%m or lcm%n: 11 lcm += 1 12 13 return lcm 方式二:公式lcm ...
分类:
编程语言 时间:
2016-12-04 00:34:09
阅读次数:
317
[codeforces 55]D. Beautiful numbers 试题描述 Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is bea ...
分类:
其他好文 时间:
2016-12-03 15:38:50
阅读次数:
232
def common_divisor(a, b): for i in range(1, min(a, b) + 1): if a % i == 0 and b % i ==0: m = i print ("The common divisor is %d" %m) 一开始对上面这段代码始终没理解,为 ...
分类:
编程语言 时间:
2016-11-30 17:11:33
阅读次数:
154
【题目链接】 http://poj.org/problem?id=2429 【题目大意】 给出最大公约数和最小公倍数,满足要求的x和y,且x+y最小 【题解】 我们发现,(x/gcd)*(y/gcd)=lcm/gcd,并且x/gcd和y/gcd互质 那么我们先利用把所有的质数求出来Pollard_R ...
分类:
其他好文 时间:
2016-11-24 07:08:09
阅读次数:
226
存档。 找出能被两个给定参数和它们之间的连续数字整除的最小公倍数。 ...
分类:
Web程序 时间:
2016-11-21 08:16:18
阅读次数:
486
一、实验内容 1. 实验要求 定义一个判断素数的函数isprime(int n),利用该函数输出1000以内的所有素数,每行10个,最后输出一共有多少个素数。(每列对齐) 代码 运行结果 2.实验要求 求两个正整数的最大公约数和最小公倍数。用一个函数gcd(int a,int b)求最大公约数,另一 ...
分类:
其他好文 时间:
2016-11-21 07:53:50
阅读次数:
176
1. 定义一个判断素数的函数isprime(int n),利用该函数输出1000以内的所有素数,每行10个,最后输出一共有多少个素数。(每列对齐) 2.求两个正整数的最大公约数和最小公倍数。用一个函数gcd(int a,int b)求最大公约数,另一个函数lcm(int a,int b)根据求出的最 ...
分类:
其他好文 时间:
2016-11-20 19:23:28
阅读次数:
273