Project Euler #8: Largest product in a series

  • + 0 comments

    Can someone find whats wrong with my code?

    #!/bin/python3
    
    import sys
    
    
    t = int(input().strip())
    for a0 in range(t):
        n,k = input().strip().split(' ')
        n,k = [int(n),int(k)]
        num = input().strip()
        # prefix array
        marr = [int(num[0])]
        for i in range(1,len(num)):
            marr.append(marr[-1](int(num[i])))
        #print(marr)
        res = 0
        #find max prodcut
        for i in range(k,len(marr)):
            if marr[i-k] !=0:
                prod = marr[i]//marr[i-k]
            res=max(prod , res )
        res = max(res,marr[k-1])
        print(res)
    

    *