Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
636 B
2
Indexable
Never
def slovag(n):
    if n == 0:
        yield ''
    elif n == 1:
        
        
        yield '1'
        yield '0'
    else:
        for el in slovag(n-1):
            
            
               # if el[-1] != '0':
            if '000' not in el + '0':
                yield el+'0'
            yield el+'1'




def sucetPrvychk(k, n):
    res = 0
    num_of_added = 0

    for slovo in slovag(n):    

        if len(str(int(slovo))) == n:
            res += int(slovo)
            num_of_added += 1
            if num_of_added == k:
                break
            
    return res % (10**9 + 7)