11703 - N-Rings   

Description

N-Ring is a game, in which N rings are put on a stick in order, and every rings are effected by each other following the rules below:

  1. The first ring can be put on and taken off at any time.
  2. If you want to put on or take off the N-th ring, you have to put on the (N-1)-th ring, and take off all the rings from 1 to (N-2)-th. By doing so, you can put on or take off the N-th ring.

Our goal is to take off all the rings.

Hint: You can implement the following code we provided

#include<stdio.h>

void in(int);

void out(int n){

    // take off the first n rings

}

void in(int n){

    //put on the first n rings

}

int n;

int main(){

    scanf("%d",&n);

    out(n);

    return 0;

}

Input

Given an integer N, 1 <= N <= 18, meaning there are N rings.

Output

Output the answer of N-Rings in order.

“Move ring n out” means taking the n-th ring off the stick.

“Move ring n in” means putting the n-th ring on the stick.

Sample Input  Download

Sample Output  Download

Tags




Discuss