hanoi11minh_nh's blog

By hanoi11minh_nh, history, 3 hours ago, In English

Hello Codeforces,

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

I need to print the order 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.

For example: Input: 2 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!

  • Vote: I like it
  • 0
  • Vote: I do not like it