题解 | #小易的升级之路#

小易的升级之路

http://www.nowcoder.com/practice/fe6c73cb899c4fe1bdd773f8d3b42c3d

def hcf(x, y):
    # 获取最小值
   if x > y:
       smaller = y
   else:
       smaller = x
 
   for i in range(1,smaller + 1):
       if((x % i == 0) and (y % i == 0)):
           hcf = i
 
   return hcf
l1=[]
l2=[]
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
for i in l2:
 if(l1[1]>=i):
    l1[1]=l1[1]+i
 else:
    l1[1]=hcf(l1[1],i)+l1[1]
print(l1[1])
l1=[]
l2=[]
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
for i in l2:
 if(l1[1]>=i):
    l1[1]=l1[1]+i
 else:
    l1[1]=hcf(l1[1],i)+l1[1]
print(l1[1])
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务