fork(3) download
  1. import random
  2.  
  3. n,s=input().split()
  4. n=int(n)
  5. s=int(s)
  6. random.seed(s)
  7. zero_times=0
  8. position=0
  9. while zero_times<n:
  10. toss=random.randint(0,1)
  11. print(toss)
  12. if toss==0: #when heads occurs
  13. position=position+1
  14. else: #when tails occurs
  15. position=position-1
  16.  
  17. if position==0:
  18. zero_times=zero_times+1
  19.  
  20. print()
Success #stdin #stdout 0.02s 37064KB
stdin
7 7
stdout
1
0
1
0
0
0
1
0
0
0
0
1
1
0
0
0
1
0
0
0
0
1
0
0
0
0
1
1
0
0
1
0
0
0
1
0
0
0
0
1
1
1
1
1
1
1
0
0
0
0
1
1
1
1
1
0
0
1
0
1
0
1
1
0
0
1
1
1
1
1
0
0
1
1
0
0
1
1
1
1
1
0
1
1
0
0
1
0
0
1
0
0
1
1
1
0
0
1
1
1
0
1
1
1
1
1
0
0
0
0
0
0
0
0
1
0
1
1
0
0
1
1
1
0
0
1
1
1
1
1
0
1
1
0