GCD nyoj 1007 (欧拉函数+欧几里得) GCD 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 The greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written (a,b),is the largest divisor common to a and b,For example,(1,2)=1,(12,18)=6.(a,b) can be…
#欧几里得求最大公约数 #!/usr/bin/env python #coding -*- utf:8 -*- #iteration def gcd(a,b): if b==0: return a else: return gcd(b, remainder(a, b)) #此方法仅仅书用于a和b都为正数 def gcd_1(a,b): while(b>0): rem = remainder(a,b) a = b b = rem return a def remainder(x,y): retur…