Type: Default 2000ms 256MiB

汉诺塔

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

有三根柱A、B、C,在A柱上有n块盘片,所有盘片都是大片在下面,小片放在大片上面。并依次编好序号。现要将A上的n块盘片移到C柱上,每次只能移动一片,而且在同一根柱子上必须保持上面的盘片比下面的盘片小,请输出移动方法。

输入格式

仅一个整数n(n≤20),表示A柱上的盘片数。

输出格式

输出盘片的移动步骤。

样例

input

3

output

A-1-C
A-2-B
C-1-B
A-3-C
B-1-A
B-2-C
A-1-C

限制与提示

时间限制:1s1 \text {s}

空间限制:256MB256 \text {MB}

寒假集训_01_13

Not Attended
Status
Done
Rule
XCPC
Problem
8
Start at
2025-1-13 14:00
End at
2025-1-13 17:00
Duration
3 hour(s)
Host
Partic.
39