Print out the up and down folding order of a sheet of paper.

Правка en2, от clex, 2024-12-13 19:45:51

Hello Codeforces,

I am encountering a problem that I am unable to solve:

I need to print the order from fold l to r of folding up and down a piece of paper after ( n ) times of performing two folds alternately left and right. Please use 'D' for Down and 'U' for Up. Input: n, l and r. For example: Input: 2 1 3 Output: DDU

Note that folding left means folding the right edge over the left edge, and folding right means folding the left edge over the right edge.

I have a rough idea of using a deque to store the order, but I can't figure out the exact algorithm for this problem.

Can you provide some hints?

Thank you!

Edit: Also 1<=n<=60, 1<=l<r<=2^n and r-l<=10^6

Теги need help fast

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский clex 2024-12-13 19:45:51 89 Tiny change: '\nHello Code' -> 'Hello Code'
en1 Английский clex 2024-12-12 19:45:51 671 Initial revision (published)