非数学解释
不论您的背景如何,这都是可以理解的解释。不幸的是,它确实涉及一些数学,但是对于大多数具有中学水平的人来说应该是可以理解的。
指针序列是a(n + 1)= a(na(n))的任何序列。
让我们对这个公式进行一点理解,以了解其含义。这只是意味着要找出我们在上一个术语中看到的序列中的下一个术语,往后退许多步并复制找到的术语。例如,如果到目前为止我们有序列
... 3 4 4 4 3 ?
我们将向后退3步 3
... 3 4 4 4 3 ?
^
使我们的结果4
。
现在,通常我们可以在两个方向上都无限的磁带上玩游戏,但是我们也可以在轮子上玩游戏,在经过一定数量的步骤后,我们回到序列的开头。
例如,这是序列的可视化 [1,3,1,3,1,3]
现在我们可能会注意到,轮子中的任何数字x超过轮子中的单元数n,也可能是x mod n,因为围绕轮子的每个完整电路都等于无所事事。因此,我们将只考虑所有成员小于轮子尺寸的轮子。
数学解释
指针序列是a(n + 1)= a(na(n))的任何序列。通常,这些定义是从整数到整数,但是您可能会注意到,此定义中唯一需要的是后继函数和逆函数。由于所有循环组都具有这两者,因此我们实际上可以考虑任何循环组上的指针序列。
如果我们开始寻找这些类型的功能,我们会注意到每个功能都有几个相似的功能。例如,在Z 3上,以下3个都符合我们的要求。
f1 : [1,2,2]
f2 : [2,1,2]
f3 : [2,2,1]
(这里的列表用于表示一个函数,该函数仅通过输入对列表进行索引就可以得到结果)
我们可能会注意到这些功能都是彼此“旋转”的。正式什么我通过旋转的意思是,一个函数b是一个旋转一个 IFF
现在,如果我们这里所涉及的数学的一点点,我们实际上可以证明,如果一个是一个指针序列的每转一个也是一个指针序列。因此,我们实际上将认为彼此旋转的任何序列都是等效的。
任务
给定n作为输入输出,大小为n的指针序列数。
这是代码高尔夫球,因此答案将以字节计分,而字节数越少越好。
测试用例
目前这些测试用例还不够,我有一个计算机程序来生成这些测试用例,但是这样做非常慢。如果有人想贡献更大的测试用例(他们可以验证正确),那么他们可以自由地这样做。在一些测试下面是我发现的所有功能的列表,这可能对调试很有用。由于字符限制,我无法为较大的字符添加这些字符。
如果您想要我用来生成这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