9.12 算法


k=int(nums[-1])
sumc=1
print( len(nums)%k,k)
if len(nums)%k==0:
    l=len(nums)//k
    for i in range(k):
        sumc*=int(nums[l*i:l*i+l])
    print(sumc)
elif len(nums)%k==1:
    cur=0
    l = (len(nums)-1) // k
    s,e=0,l
    for j in range(k):
        while e <= len(nums):
            if s==l*j:
                e=e+1
            sumc*=int(nums[s:e])
            print(j, s, e, sumc)
            if s==l*j:
                s=s+l+1
            else:
                s+=l
            e+=l
        cur=max(cur,sumc)
        s,e,sumc=0,l,1
    print(cur)
elif len(nums)%k==2:
    print("2fun")
    cur=0
    l = (len(nums)+1) // k
    s,e=0,l
    for j in range(k):
        while e <= len(nums)+1:
            if s==l*j:
                e=e-1
            sumc*=int(nums[s:e])
            print(j, s, e, sumc)
            if s==l*j:
                s=s+l-1
            else:
                s+=l
            e+=l
        cur=max(cur,sumc)
        s,e,sumc=0,l,1
    print(cur) 


#笔经##滴滴#
全部评论

相关推荐

冲芭芭拉鸭:你这图还挺新,偷了。
投递美团等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务