2013年8月13日
摘要: 标准广搜限制转弯次数同广搜_限制转弯次数(HDU_1728)#include #include #include using namespace std;#define M 1002struct node { int x,y,turn; node(int _x,int _y,int _turn) { x = _x; y = _y; turn = _turn; }};int map[M][M],flag[M][M];int move[4][2] = {-1,0,0,1,1,0,0,-1};queue q;int n,m;int judge(int x,int... 阅读全文
posted @ 2013-08-13 17:06 lk1993 阅读(274) 评论(0) 推荐(0)
摘要: 广搜限制转弯次数直线搜索当前位置的四个方向,把途中没有访问的点 turn 值 +1 入队。 说明:如果直线到达终点,则返回 true;如果四个方向都没有到达,则一定会转向,则退出队列中 turn值 +1 的位置;首先判断当前 turn ,如果超限制,则一定不会再有位置可以到达终点(队列中的点都是不递减的);如果没有,继续直线搜索当前位置的四个方向。#include #include #include using namespace std;#define M 102struct node { int x,y,turn; node(int _x,int _y,int _turn) ... 阅读全文
posted @ 2013-08-13 17:00 lk1993 阅读(249) 评论(0) 推荐(0)
摘要: 十六进制六十四位不能直接输出负数,要判断输出。#include #include int main(int argc, char* argv[]){ #ifdef __MYLOCAL freopen("in.txt","r",stdin); #endif __int64 A,B,C; while(scanf("%I64X%I64X",&A,&B) != EOF) { C = A + B; if(C < 0) { C = -C; printf("-"); } ... 阅读全文
posted @ 2013-08-13 13:41 lk1993 阅读(154) 评论(0) 推荐(0)
摘要: ^_^#include #include #include using namespace std;#define M 500002int mu[M],d[M];int lis(int n) //n*lg(n){ d[1] = mu[1]; int len = 1; for(int i=2; i> 1; if(d[mid] len) len++; } return len;}int main(int argc, char* argv[]){#ifdef __MYLOCAL freopen("in.txt","r",stdin);#en... 阅读全文
posted @ 2013-08-13 13:35 lk1993 阅读(172) 评论(0) 推荐(0)
摘要: #include #include #define M 1002char map[M][220] = {"0","1","1"};void add(char *aStr, char *bStr, char *cStr)//aStr + bStr = cStr{ int ai = strlen(aStr)-1,bi = strlen(bStr)-1,ci = 0; int all,over = 0; for(; ai>=0 || bi>=0; ai--,bi--) { all = (ai>=0 ? aStr[ai]-& 阅读全文
posted @ 2013-08-13 13:30 lk1993 阅读(175) 评论(0) 推荐(0)