fork download
  1. -module(prog).
  2. -export([main/0]).
  3.  
  4. main() ->
  5. loop().
  6.  
  7. large_queue(0) -> queue:new();
  8. large_queue(N) -> queue:in(N, large_queue(N-1)).
  9.  
  10. pop(Q) -> {A, B} = queue:out(Q), B.
  11.  
  12. pop_r(Q) -> {A, B} = queue:out_r(Q), B.
  13.  
  14.  
  15. funny_pop({[],[]}) -> true;
  16. funny_pop(Q) -> funny_pop(pop_r(pop(Q))).
  17.  
  18. loop() ->
  19. case io:fread( "","~d" ) of
  20. eof ->
  21. true;
  22. {ok, X} ->
  23. [Y] = X,
  24. Q = large_queue(Y),
  25. funny_pop(Q),
  26. true
  27. end.
Time limit exceeded #stdin #stdout 5s 21192KB
stdin
100000
stdout
Standard output is empty