spiral grid
时间限制:
2000
ms
|
内存限制:
65535
KB
难度:
4
-
描述
-
Xiaod has recently discovered the grid named "spiral grid".
Construct the grid like the following figure. (The grid is actually infinite. The figure is only a small part of it.)
Considering traveling in it, you are free to any cell containing a composite number or 1, but traveling to any cell containing a prime number is disallowed. In addition, traveling from a prime number is disallowed, either. You can travel up, down, left or right, but not diagonally. Write a program to find the length of the shortest path between pairs of nonprime numbers, or report it's impossible.
-
-
输入
- Each test case is described by a line of input containing two nonprime integer 1 <=x, y<=10,000. 输出
- For each test case, display its case number followed by the length of the shortest path or "impossible" (without quotes) in one line. 样例输入
-
1 4
-
9 32
-
10 12
样例输出
-
Case 1: 1
-
Case 2: 7
-
Case 3: impossible
#include
#include
#include
using namespace std;
int m[105][105], a, b, vis[105][105], su[10005] = {0}, dirx[4] = {0,0,1,-1}, diry[4] = {1,-1,0,0};
typedef struct node
{
}node;
void prime()
{
}
void store()
//打一个蛇形数组
{
}
int bfs(int x, int y)
//普通广搜
{
}
int main()
{
}