Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- res=[]
- while(1):
- teste = input()
- lista = teste.split()
- assert(len(lista) == 2)
- for i in range(2):
- lista[i] = int(lista[i])
- if lista == [0,0]:
- funcprint(res)
- return
- funcinp(lista,res)
- def funcinp(lista,res):
- vals = []
- tam = lista[0]
- valor = lista[1]
- for i in range(tam):
- aux = (input())
- aux2 = aux.split()
- val = int(aux2[0])
- vals.append(val)
- for i in range (tam+1):
- #j=i
- #print("j= " + str(j) + " no i= " +str(i))
- for j in range(i,tam+1):
- soma = 0
- #z = i
- #print("j= " + str(j) + " no range")
- #print("Z no j" + str(z) )
- for z in range(i,j):
- soma += vals[z]
- print("Z dentro do range" + str(z))
- if soma == valor:
- res.append(i+1)
- return
- res.append(0)
- return
- def funcprint(res):
- for i in range(len(res)):
- if res[i] == 0:
- print("SEQUENCIA NAO ENCONTRADA")
- else:
- print("SEQUENCIA NA POSICAO " + str(res[i]))
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement