Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. def main():
  2. res=[]
  3. while(1):
  4. teste = input()
  5. lista = teste.split()
  6. assert(len(lista) == 2)
  7. for i in range(2):
  8. lista[i] = int(lista[i])
  9. if lista == [0,0]:
  10. funcprint(res)
  11. return
  12.  
  13. funcinp(lista,res)
  14.  
  15.  
  16. def funcinp(lista,res):
  17. vals = []
  18. tam = lista[0]
  19. valor = lista[1]
  20. for i in range(tam):
  21. aux = (input())
  22. aux2 = aux.split()
  23. val = int(aux2[0])
  24. vals.append(val)
  25. for i in range (tam+1):
  26. #j=i
  27. #print("j= " + str(j) + " no i= " +str(i))
  28. for j in range(i,tam+1):
  29. soma = 0
  30. #z = i
  31. #print("j= " + str(j) + " no range")
  32. #print("Z no j" + str(z) )
  33. for z in range(i,j):
  34. soma += vals[z]
  35. print("Z dentro do range" + str(z))
  36. if soma == valor:
  37. res.append(i+1)
  38. return
  39. res.append(0)
  40. return
  41.  
  42. def funcprint(res):
  43. for i in range(len(res)):
  44. if res[i] == 0:
  45. print("SEQUENCIA NAO ENCONTRADA")
  46. else:
  47. print("SEQUENCIA NA POSICAO " + str(res[i]))
  48.  
  49. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement