当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2876:Cantoring Along

题目描述
The Cantor set was discovered by Georg Cantor. It is one of the simpler fractals. It is the result of an infinite process, so for this program, printing an approximation of the whole set is enough. The following steps describe one way of obtaining the desired output for a given order Cantor set:
  1. Start with a string of dashes, with length 3order

  2. Replace the middle third of the line of dashes with spaces. You are left with two lines of dashes at each end of the original string.

  3. Replace the middle third of each line of dashes with spaces. Repeat until the lines consist of a single dash.
For example, if the order of approximation is 3, start with a string of 27 dashes:
---------------------------
Remove the middle third of the string:
---------         ---------
and remove the middle third of each piece:
---   ---         ---   ---
and again:
- -   - -         - -   - -
The process stops here, when the groups of dashes are all of length 1. You should not print the intermediate steps in your program. Only the final result, given by the last line above, should be displayed.
输入解释
Each line of input will be a single number between 0 and 12, inclusive, indicating the order of the approximation. The input stops when end-of-file is reached.
输出解释
You must output the approximation of the Cantor set, followed by a newline. There is no whitespace before or after your Cantor set approximation. The only characters that should appear on your line are '-' and ' '. Each set is followed by a newline, but there should be no extra newlines in your output.
输入样例
0
1
3
2
输出样例
-
- -
- -   - -         - -   - -
- -   - -

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Mid-Atlantic 2002

源链接: POJ-2876

最后修改于 2020-10-29T06:46:34+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536