摘要: 每个点加4个方向View Code #include <stdio.h>#include <string.h>#include <queue>using namespace std;struct node{ int x,y,dir,step; friend bool operator <(node aa, node bb) { return aa.step>bb.step; }}a;int n,m,k,x1,y1,x2,y2;char map[105][105];int dp[105][105][4];int d[4][2]={0,1,1,0,0 阅读全文
posted @ 2012-11-04 14:16 104_gogo 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 思路很简单直接暴力,只是代码复杂了点View Code #include <iostream>#include <string>#include <map>#define Min -0x3f3f3f3fusing namespace std;map<string,int> m;struct node{ int k,val[25],name[25];}ar[5];int cnt,ans,vis[25],Map[25][25];int judge(){ int i,j,num=0; for (i=0;i<10;i++) { for (j=i+1 阅读全文
posted @ 2012-07-12 17:00 104_gogo 阅读(368) 评论(0) 推荐(0) 编辑
摘要: 照着题目的意思打代码就行了,这里我是用邻接表建的图。先把A的所有朋友找到(统称为B),并且标记,再去找B的朋友,如果B的朋友不是A的朋友,按字典序输出出现次数最多的。View Code #include <iostream>#include <string>#include <map>#include <queue>using namespace std;map<string,int> m1;map<int,string> m2;struct node{ int to,pre;}Map[100000];struct Nod 阅读全文
posted @ 2012-07-12 15:32 104_gogo 阅读(150) 评论(0) 推荐(0) 编辑
摘要: &的数字越多值越小,所以一直递归下去值是变小的View Code #include <stdio.h>#include <algorithm>using namespace std;int n,k;__int64 ar[50],ans;void init(){ int i; scanf("%d%d",&n,&k); for (i=0;i<n;i++) scanf("%I64d",&ar[i]); sort(ar,ar+n);}int judge(int id,__int64 num){ int 阅读全文
posted @ 2012-07-12 10:57 104_gogo 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 直接暴力,不过加了点优化:1.如果你求出50的答案是126,那么50-126的答案都是126了;2.求10的时候,只用循环到有答案的那个(比如是50)就行了,不用到126了。View Code #include <stdio.h>#include <math.h>#include <string.h>int ans[1000305],ar[10],now;int judge(int a,int b,int c){ int i,num[10]={0}; while (a) { num[a%10]++; a/=10; } while (b)... 阅读全文
posted @ 2012-04-26 10:37 104_gogo 阅读(326) 评论(0) 推荐(0) 编辑
摘要: View Code #include <stdio.h>int n,m,ans;int dir[4][2]={-1,0,0,-1,0,1,1,0};//上左右下int ar[12][4]={{1,1,0,0},{1,0,1,0},{0,1,0,1},{0,0,1,1}, {1,0,0,1},{0,1,1,0},{1,1,1,0},{1,1,0,1}, {0,1,1,1},{1,0,1,1},{1,1,1,1}};char map[55][55];void dfs(int x,int y,int a){ int i,j,b,row,col; m... 阅读全文
posted @ 2011-12-24 23:22 104_gogo 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 我自己想了个嵌套的队列,就像是嵌套循环来枚举一样有多少个起点,每个起点可以走五步,如果能走到4这个点,则4这个点又可以作为起点,加入外层队列View Code #include <stdio.h>#include <string.h>#include <queue>using namespace std;struct node{ int x,y,step;}a;int n,m,ans,map[9][9],tmp[9][9],used[9][9];void bfs(){ queue<node> p; p.push(a); int i,cnt,row 阅读全文
posted @ 2011-12-24 10:37 104_gogo 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 蛋疼,犯了2个错误1.不能每遇到个点都把它四个方向的每个点都走一个(每个点入一次队列),这样要mle2.不能把已经走过的点标记成‘*’,这样要waView Code #include <stdio.h>#include <queue>using namespace std;struct node{ int x,y,cnt;}a;int n,m,ex,ey,k;char map[105][105];int bfs(){ int i,row,col,dir[4][2]={0,1,1,0,-1,0,0,-1}; queue<node> q; q.push(a); 阅读全文
posted @ 2011-12-22 17:59 104_gogo 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 自己改了很久,老是出错,最后发现在把一张牌 i 选出来放在另一张牌 j 上出了问题,但如果要改的话,就要去找牌 i 能放的唯一一张牌 j 又不方便最后不得不佩服那些把输入处理成id[x]=i;这样的人,写的很精彩。View Code #include<stdio.h>#include<math.h>int mark[11],id[11],ans;void dfs(int num,int sum){ int i,j; if(sum>=ans)return; if(num==9) { ans=sum; return; } for(i=... 阅读全文
posted @ 2011-12-22 14:48 104_gogo 阅读(371) 评论(0) 推荐(0) 编辑
摘要: 用到了图论最短路更新的思想,当走到走过的地方时要更新数据:5 6.XX.1...X.6.2...X....XX.XXXXX.View Code #include <stdio.h>#include <string.h>#include <queue>using namespace std;struct node{ int x,y,num,t;}a;struct Path{ int x,y,pre,fight;}p[500000];int n,m,k,l,key,dp[105][105];char map[105][105];void f(int z){ in 阅读全文
posted @ 2011-12-22 14:34 104_gogo 阅读(98) 评论(0) 推荐(0) 编辑