摘要: 简单题View Code #include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>usingnamespacestd;#definemaxn555charst[maxn][maxn];intdir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};intn,m;boolok(intx,inty){if(x<0||y<0||x>=n||y>=m)returnfalse;if(st[x][y]!=0)returnfalse;ret 阅读全文
posted @ 2011-07-13 20:42 undefined2024 阅读(262) 评论(0) 推荐(0)
摘要: 简单题printf("%x", d) 十六进制View Code #include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>usingnamespacestd;intr,x,y;intmain(){//freopen("t.txt","r",stdin);scanf("%x,%d,%d",&r,&x,&y);inta=1;if((a<<x)&r)r 阅读全文
posted @ 2011-07-13 20:26 undefined2024 阅读(152) 评论(0) 推荐(0)
摘要: trieView Code #include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>usingnamespacestd;#definemaxl15#definemaxn10005structNode{Node*next[10];boolhave;boolend;}trie[maxn*maxl];intn;charst[maxl];intncount;boolins(Node*proot,char*st){if(proot->end)returnfalse;if( 阅读全文
posted @ 2011-07-13 20:00 undefined2024 阅读(230) 评论(0) 推荐(0)
摘要: dpView Code #include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>usingnamespacestd;intf[6][50];intmain(){//freopen("t.txt","r",stdin);memset(f,0,sizeof(f));f[0][0]=1;for(inti=1;i<=5;i++)for(intj=0;j<=9*i;j++)for(intk=0;k<=9;k++){if( 阅读全文
posted @ 2011-07-13 19:12 undefined2024 阅读(252) 评论(0) 推荐(0)
摘要: bfsView Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxx 1005#define inc 502#define maxn maxx * maxxstruct Point{ int x, y;} q[maxx * maxx];int n, cx, cy;bool vis[maxx][maxx];bool map[maxx][maxx];int dist[maxx][maxx 阅读全文
posted @ 2011-07-13 11:05 undefined2024 阅读(138) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;string st[16];int length[16];char a[6000000];int getid(char *a){ int len = strlen(a); for (int i = 0; i <= 15; i++) if (len == length[i]) return i; return -1;}int main( 阅读全文
posted @ 2011-07-13 10:03 undefined2024 阅读(190) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int n, m, c;int main(){ //freopen("t.txt", "r", stdin); while (scanf("%d%d%d", &n, &m, &c), n | m | c) { if ((n + m) & 1) c = 阅读全文
posted @ 2011-07-13 09:33 undefined2024 阅读(169) 评论(0) 推荐(0)
摘要: 题意,给定一个01矩阵,要求从0矩阵变换得到该结果,变换的方法是把一个绝对r*c大小的方格内的元素改变(0变1,1变0)。最少多少步。分析:我们可以知道如果想改变左上角的方格内的元素,则方法只有一种,即最左上角的r*c是否改变是确定的。在操作完成后,想改变第二行第一列以及第一行第二列的元素,并保持左上角元素不变的方法也分别只有一种。依次类推。可发现整个的方法是确定的。改变后判断结果与要求的结果是否相同即可。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include < 阅读全文
posted @ 2011-07-13 08:37 undefined2024 阅读(437) 评论(0) 推荐(0)