shunfurh 于 2016.12.31 23:07 提问

Cantoring Along

Description

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:
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.
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.
Input

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.
Output

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.
Sample Input

0
1
3
2
Sample Output

• - - - - - - - - - - - - -

1个回答

caozhy      2016.12.31 23:29

Cantoring Along pku2876
Cantoring Along Time Limit:1000MS  Memory Limit:65536KTotal Submit:1310 Accepted:788 DescriptionThe Cantor set was discovered by Georg Cantor. It is one of the simpler fractals. It is the result of
POJ 2876 Cantoring Along 递归
【题意简述】：本题让我们输入单位为3的“-”的个数，接下来对这条线进行切割，每次切掉中间的三分之一，用空格替换，直到“-”的每一段长度为1，打印输出。 【思路】：递归题，用时稍久，希望你写出用时更短的代码。我们可以将一个数组赋值为空格，然后对该数组进行分割，同样满足题意，每次丢掉中间的三分之一，然后递归循环此过程，将其划分的更小，直到分割到长度为1，结束返回。。 /* 1128K 375Ms
Android编译遇到点9图片错误：No marked region found along edge. - Found along left edge.
http://androidren.com/index.php?qa=330&qa_1=android%E7%BC%96%E8%AF%91%E9%81%87%E5%88%B0%E7%82%B99%E5%9B%BE%E7%89%87%E9%94%99%E8%AF%AF%EF%BC%9Ano-marked-region-found-along-found-along 这个是因为点9图的某一个

Instance Along Curve - Maya API Plugin

Python科学计算-----NumPy（一）
Numpy NumPy 是 Numerical Python 的简称，是Python的高性能计算和数据分析的基础核心包。与Python的基本数据类型相比，其具有以下突出优势： 提供功能更强大的高维数组（N-dimensional）对象 强大的广播功能（broadcasting），便于矢量化数组操作（直接对数组进行数据处理，而不需要编写循环） 集成了 C/C++ 以及 Fortr
IndexError:boolean index did not match indexed array along dimension 0
IndexError: boolean index did not match indexed array along dimension 0; dimension is 8 but corresponding boolean dimension is 7在学习回归算法的时候，使用sklearn.linear_model下的RandomizedLogisticRegression（下列简称为RLR...
Error:Can't have more than one marked region along edge.

Poj 3069 Saruman's Army【贪心】
Saruman's Army Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5742   Accepted: 2942 Description Saruman the White must lead his army along a straight pa
.9图片报错mergeDebugResources. xx.9.png Can't have more than one marked region along edge