摘要: 转载于http://www.cnblogs.com/yezhenhan/archive/2011/11/06/2238452.html语言位运算符:与、或、异或、取反、左移和右移位运算是指按二进制进行的运算。在系统软件中,常常需要处理二进制位的问题。C语言提供了6个位操作运算符。这些运算符只能用于整型操作数,即只能用于带符号或无符号的char,short,int与long类型。C语言提供的位运算符列表:运算符 含义 描述& 按位与 如果两个相应的二进制位都为1,则该位的结果值为1,否则为0| 按位或 两个相应的二进制位中只要有一个为1,该位的结果值为1^ 按位异或 若参加运算的两个二进 阅读全文
posted @ 2012-06-11 17:27 LJ_COME!!!!! 阅读(153) 评论(0) 推荐(0)
摘要: 哈希技术#include <stdio.h>#include <stdlib.h>#include <memory.h>#define maxn 1003typedef struct{ int x; int y;}Node;Node sq[1003];typedef struct THashTable{ int x,y; THashTable* next;}HashTable;HashTable* hash[maxn];void InsertHT(int i)//构建哈希表{ int key=(sq[i].x)*(sq[i].x)+(sq[i].y)*(sq 阅读全文
posted @ 2012-06-11 15:49 LJ_COME!!!!! 阅读(130) 评论(0) 推荐(0)
摘要: 本题哈希,但judge的时间还是很长,哎;#include <stdio.h>#include <memory.h>#define maxn 100003struct s{ int arms[6]; int amount;}snow[maxn];int head[maxn],next[maxn];//maxn大小的哈希表int judge(int *a,int *b){ int i,j,ok=1,t=0; int k[6]; for(i=0;i<6&&ok;i++) { for(j=0;j<6;j++) { if(a[i]==b[j]) { 阅读全文
posted @ 2012-06-07 20:29 LJ_COME!!!!! 阅读(92) 评论(0) 推荐(0)
摘要: 这道题用了两个多小时,调试了n次后发现是变量w的问题,得到的教训就是以后要改变量的值时要考虑改变了的变量值对后续的工作有没有影响。 阅读全文
posted @ 2012-06-02 17:10 LJ_COME!!!!! 阅读(78) 评论(0) 推荐(0)
摘要: BFS+剪枝#include <stdio.h>#include <memory.h>int prime[10000];int st,fin;void Prime(){ int i,j; for(i=2;i<10000;i++) { if(!prime[i]) { for( j=i+i;j<10000;j+=i) { prime[j]=1; } } }}int getvalue(int a[]){ int m=0; for(int i=3;i>=0;i--) { m=m*10+a[i]; } return m;}int bfs(int st,int f 阅读全文
posted @ 2012-06-02 17:04 LJ_COME!!!!! 阅读(106) 评论(0) 推荐(0)
摘要: 半小时就写完了代码,提交后,一直是wa,煎熬了两小时后发现,忘了考虑在同一点这一情况#include <stdio.h> #include <memory.h> const int maxn=200000+10; int N,K; int queue[maxn]; int visit[maxn]={0}; int dis[maxn]; int bfs(int N,int K) { int font=0; int rear=0; queue[rear++]=N; visit[N]=1; int tem; while(font<rear) { int w=queue[ 阅读全文
posted @ 2012-05-29 19:06 LJ_COME!!!!! 阅读(111) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <memory.h> const int maxn=40+10; int visit[maxn*maxn]; int map[maxn][maxn]; int m,n; int dir[4][2]={{0,-1},{-1,0},{0,1},{1,0}}; int step1; int step2; void dfs1(int step ,int way,int tem) { int x=tem/n; int y=tem%n; if(map[x][y]=='E'){ step1=step; retur 阅读全文
posted @ 2012-05-29 16:14 LJ_COME!!!!! 阅读(124) 评论(0) 推荐(0)
摘要: 路径模拟+dfs#include <stdio.h>const int maxn=128+10;char terminal[maxn];char outcome[maxn];int n;char order[8];int amount=0;char s[8][2];char dfs(int height,int loc){ if(height==n) return terminal[loc-1]; int a=s[height][1]-'0'; int b=order[a-1]-'0'; if(b==0) return(dfs(height+1,lo 阅读全文
posted @ 2012-05-27 15:00 LJ_COME!!!!! 阅读(171) 评论(0) 推荐(0)
摘要: 伤不起呀#include <stdio.h>int n;int flag;char inputFilter(){ char c; while(scanf("%c",&c)&&c==' '||c=='\n'||c==9||c==10); return c;}int dfs(int sum,int height){ char c; int sign=1; int count=0; c=inputFilter();//个人认为此处是本题的关键点1 if(c==')') return height; 阅读全文
posted @ 2012-05-26 18:30 LJ_COME!!!!! 阅读(102) 评论(0) 推荐(0)
摘要: BFS#include <stdio.h>#include <memory.h>#include <stdlib.h>const int maxn=15;int visit[maxn*maxn];int dir[8][2]={{-2,-1},{-2,1},{-1,2},{1,2},{2,1},{2,-1},{1,-2},{-1,-2}};char a[3];char b[3];int bfs(int st,int fin);int main(){ while(scanf("%s",a)!=EOF) { scanf("%s&quo 阅读全文
posted @ 2012-05-22 19:46 LJ_COME!!!!! 阅读(112) 评论(0) 推荐(0)