2014年1月24日

Prime Path

摘要: poj3126:http://poj.org/problem?id=3126题意:给你两个数n,k,两个数都是四位数的素数。现在让你改变n的一位数,让n变成另外一个素数。然后把这个素数在改变其中的以为又变成一个新的素数,问你最少有这样变换几步,才能使得使他变成k。题解:求最短的问题,很自然的就想到了BFS,此外这一题还要处理10000以内的素数,可以采用素数筛法。#include#include#include#include#includeusing namespace std;int prime[100001];//标记该数是不是素数struct Node{ int x; int step 阅读全文

posted @ 2014-01-24 16:40 天依蓝 阅读(484) 评论(0) 推荐(1) 编辑

导航