什么是总理广场?
素数平方是所有四个边都是不同素数的平方。
但是哪个呢?
我们如何构造它们?
这是4x4 Prime Square的示例
1009
0 0
3 0
1021
首先,我们从左上角开始。我们正在顺时针工作。
我们选择4
数字为1009的最小素数。
然后,我们需要具有4
数字的最小素数,该素数以开头9
。这是9001
第三个(4位数字)素数必须1
以最后一位数字(因为9001以结尾1
)
,并且必须是具有此属性的最小的4位素数,此属性以前没有用作edge。
这个素数是1021
第四个质数必须具备4
数字,开始了1
(因为1009点开始有1
),并结束了1
(因为1021点开始有1
)
与此属性的最小的4位质数尚未为边缘之前使用的是1031
你的任务
您将获得一个整数n
,3 to 100
该整数将是该n x n
正方形的尺寸。
然后,您必须按照以下测试用例的形式准确输出该正方形
测试用例
n=3
Output
101
3 0
113
n=5
Output
10007
0 0
0 0
9 0
10061
n=7
Output
1000003
0 0
0 0
0 0
0 0
8 1
1000037
n=10
Output
1000000007
0 0
0 0
0 0
0 0
0 0
0 0
1 0
8 0
1000000021
n=20
Output
10000000000000000051
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
9 8
10000000000000000097
- 输入和输出可以通过任何方便的方法给出。
- 您可以将其打印到STDOUT或将其作为功能结果返回。
- 完整的程序或功能都是可以接受的。
- 只要数字适当排列,任何数量的外部空格都是可以接受的
- 禁止出现标准漏洞。
- 这是代码高尔夫球,因此所有常见的高尔夫规则都适用,并且最短的代码(以字节为单位)获胜。
编辑
这对所有人来说n
都是可能的n=100
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000289
9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000091
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000711
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002191
对于那些您认为不可能实现的人,这里是所有测试用例
n
:P 都可行?挑战不是问题,只是好奇。
n
:对于n
= 1,我们不能满足四个边缘是素数的约束,而对于n
= 2,我们被迫选择11,13,23,此时最终边缘是12是复合的。我没有证据表明所有n
> 2 都是可能的,但是如果不这样做,我会感到震惊:非正式地,数字越多,满足约束的“摆动空间”越多。