Project Euler 313
Project Euler 313
题目
Sliding game
In a sliding game a counter may slide horizontally or vertically into
an empty space. The objective of the game is to move the red counter
from the top left corner of a grid to the bottom right corner; the space
always starts in the bottom right corner. For example, the following
sequence of pictures show how the game can be completed in five moves on
a
Let
There are exactly
How many grids does
解决方案
以一个比较低效的广度优先搜索打印出一部分
1 | N = 15 |
可以发现以下规律:
不难证明,不存在一个平方数,其模
对于每一个质数
联立第一个和第二个,得到
枚举所有质数
代码
1 | # include <bits/stdc++.h> |