【POJ - 3126】Prime Path(bfs)】的更多相关文章

Prime Path 原文是English 这里直接上中文了 Descriptions: 给你两个四位的素数a,b.a可以改变某一位上的数字变成c,但只有当c也是四位的素数时才能进行这种改变.请你计算a最少经过多少次上述变换才能变成b.例如:1033 -> 8179 1033 1733 3733 3739 3779 8779 8179最少变换了6次.Input 第一行输入整数T,表示样例数. (T <= 100) 每个样例输入两个四位的素数a,b.(没有前导零) Output 对于每个样例,输…
BUPT2017 wintertraining(16) #5 B POJ - 2251 题意 3维的地图,求从S到E的最短路径长度 题解 bfs 代码 #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #define N 35 using namespace std; struct node{ int x,y,z,d; }s,e; int L,R,C; int…
-->Meteor Shower Descriptions: Bessie听说有场史无前例的流星雨即将来临:有谶言:陨星将落,徒留灰烬.为保生机,她誓将找寻安全之所(永避星坠之地).目前她正在平面坐标系的原点放牧,打算在群星断其生路前转移至安全地点. 此次共有M (1 ≤ M ≤ 50,000)颗流星来袭,流星i将在时间点Ti (0 ≤ Ti  ≤ 1,000) 袭击点 (Xi, Yi) (0 ≤ Xi ≤ 300; 0 ≤ Yi ≤ 300).每颗流星都将摧毁落点及其相邻四点的区域. Bess…
[题目链接]click here~~ [题目大意]给你n,m各自是素数,求由n到m变化的步骤数,规定每一步仅仅能改变个十百千一位的数,且变化得到的每个数也为素数 [解题思路]和poj 3278类似.bfs+queue,分别枚举个十百千的每一位就能够了,只是注意个位仅仅能为奇数,且千位从1開始 代码: #ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno&g…
The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices.- It is a matter of security to change such things every now and then, to…
Prime Path Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 987    Accepted Submission(s): 635 Problem Description The ministers of the cabinet were quite upset by the message from the Chief of S…
Prime Path Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Total Submission(s) : 21   Accepted Submission(s) : 18 Problem Description The ministers of the cabinet were quite upset by the message from the Chief of Sec…
题目传送门  Prime Path The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices. — It is a matter of security to change such things ever…
一直不明白为什么我的耗时几百毫秒,明明差不多的程序啊,我改来改去还是几百毫秒....一个小时后:明白了,原来把最大值0x3f(77)取0x3f3f3f3f就把时间缩短为16ms了.可是为什么原来那样没有WA呢?哦,明白了,因为最大值写小了,dicnic会多跑几遍.嗯顺便:0x3f3f3f3f也就是1061109567,也就是10^9级别的,是一个很大的数,而且加上一个10^9级别以下的数字也不会溢出.所以很多时候最大值取这个会比较好.最大的int是0x7fffffff,可以用常量INT_MAX…
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2296 [题目大意] 给出一个数x,求一个10的16次以内的数使得其被x整除并且数字包含0到9所有数字 [题解] 我们构造数前10位为0到9,利用后面六位补充使得其为x的倍数,x为10的6次方以内, 因此除x=0的特殊情况外一定存在解. [代码] #include <cstdio> using namespace std; int T,x; int main(){ scanf(&qu…