- 博客(85)
- 资源 (5)
- 收藏
- 关注
原创 aes verilog实现
源码下载页:http://download.csdn.net/detail/a1003zoucun/6907185
2014-02-09 16:21:12 5397 2
原创 BST简单测试
纸上得来终觉浅,绝知此事要躬行。#include using namespace std;struct node { int nt,val; node *r,*l;};void insert(int v , node *&t){ if(t==NULL) { t=new node; if(t==NULL) cout<<" error "<<endl; else
2013-09-05 23:13:46 2150
原创 欧拉回路 + 数据结构 + dfs
poj 2230这个题确实很经典。刚开始的时候想了好久,一直没想明白怎么去遍历所有的点两遍。搜了,别人的解题报告。顿悟,标记边啊。太弱了。。然后保存成动态邻接表的形式。深搜一遍就过了。。后来看到一大牛博客上的解法,瞬间,觉得,那种相对邻接表保存的数据结构,简直碉堡了,神牛果然是用来学习的。。邻接表:#include #include #include #define N 1000
2013-05-09 17:08:01 698
原创 欧拉回路 + 并查集 + 连通图
#include#include #include #include #define N 100005using namespace std;bool v[N];int a1[N],a2[N];int n,m,f[N],r[N],d[N];void init(){ memset(v, 0 ,sizeof(v)); memset(a1,0,sizeof(a1)); mems
2013-05-08 21:21:23 517
原创 欧拉路与欧拉回路的判断 poj 1386
点击打开链接#include #include #include #define N 100005#define M 26using namespace std;bool a[N];int t,n,in[N],out[N],f[N],r[N];void init(){ for(int i=0 ; i<=M ; i++) f[i]=i,r[i]=0;}int
2013-05-08 18:02:07 510
原创 欧拉回路
点击打开链接#include #define N 1005using namespace std;bool a[N][N];int n,m,d[N],r[N],f[N];void init(){ for(int i=1 ;i<=n ; i++) f[i]=i,r[i]=1;}int find(int k){ return f[k]=(f[k]!=k?find(f[k]
2013-05-08 16:14:26 409
原创 克鲁斯卡尔算法模板(并查集完美结合)
#include #include #include #define N 10005using namespace std;int f[N],rank[N];struct node{ int x,y,val;}e[N];bool operator<(node a , node b){ return a.val<b.val;}void init_set(){ for(
2013-04-04 22:47:39 1528
原创 最小生成树问题 普利姆算法简单模板 hdoj1233
#include #include #include #define N 105using namespace std;int n,m,a[N][N],b[N];;const int inf=0x3f3f3f3f;int prim(){ int i,j,t,k,s,f[N],r=0; memset(f,0,sizeof(f)); for(t=i=f[1]=1 ; i<n
2013-04-03 23:50:18 553
原创 小希的数表
不管怎么说这个题目只能算一个简单题,黑书上提供了一种方法,递推求解!但是,这道题 ,其实并不需要 ,动什么脑筋,纯粹的模拟一番就出来了。关键点在于每个存在的数,只能用一次。穷举+hash检索。hdoj 1270#include #include #include #include #define M 100005using namespace std;int main (){
2013-03-01 18:56:09 927
原创 ai=?
一个很简答的数学递推找规律的题,很久以前,记得自己连这种题目都搞不定 ,哎,这次又碰到了,各种感觉曾杂,贴着留个纪念吧。#include#include#includeusing namespace std;int main (){ //freopen("1.txt","r",stdin); int n,i; double a0,an1,c,s; while(scanf("%
2013-03-01 18:50:09 338
原创 串操作
/*kmp 模式匹配算法 (求最长共串 匹配问题 求最大周期) */#include #include #include #define N 100using namespace std;int next[N];void getnext(string s){ int i , j; memset(next,0,sizeof(next)); n
2013-02-21 16:40:24 280
原创 队列操作
/* 静态队列操作 */#include #define N 10using namespace std;struct dqueue{ int *base; //队列地址 int *front; //队首指针 int *rear; //队尾指针 int qsize; //队列的大小};void InitQueue(dqueue &q)
2013-02-03 20:31:36 1339
原创 栈的应用
/* 括号匹配与检测 */#include #include #include using namespace std;int check(char c){ if(c=='[') return 1; if(c=='(') return 1; return 0;}int ok(char x , char y){ if(x==
2013-02-03 20:22:44 332
原创 栈操作
/* 栈操作 */#include #include #include #include #define N 10#define LEN 10using namespace std;struct stack{ int *base; int *top; int stacksize;};void InitStack(stack &
2013-02-03 20:17:04 397
原创 双向链表操作
/* 双向链表 */#include #include #include #include #include #include #include #define M 20#define LEN 15using namespace std;struct node{ int coef;//指数 int data;//数
2013-02-03 20:13:50 382
原创 线性表 和 多项式相乘
/* C语言线性表 采用c语言 malloc realloc free 实现类存分配 */#include #include #include #include #include #include #include #define LS 1000#define LS_M 100using namespace std;/*说明:本程序从0号
2013-02-03 20:06:52 494
原创 Eddy's 洗牌问题
/* 对于数学相关的题,一直比较差,硬伤! */列出所有情况终于找到规律:1:1 2 11 2->2 1->1 2 2:1 2 4 3 11 2 3 4 ->3 1 4 2 -> 4 3 2 1 -> 2 4 1 3 -> 1 2 3 4 3:1 2 4 11 2 3 4 5 6-> 4 1 5 2 6 3 -> 2 4 6 1 3 5 -> 1
2013-01-02 15:52:43 320
原创 字串数
/* 十分简单的一个题目,无非就是一个带重复的排列,可惜,哥的数学知识不知道被什么给吃了,带重复的全排列的搞不定了,直接弱爆了,对于重复排列如何理解现在还不是很懂,求强势证明 !*/import java.io.*;import java.util.*;import java.math.*;public class Main{ static int m=0,c=0,a[]=new
2013-01-02 13:57:29 334
原创 Bad Hair Day
/* 统被看到牛的头的个数,只要有较高的牛挡住了,就看不到后面牛的个数 ,注意是从左往右看 */#include #include #include #define N 1000005using namespace std;typedef __int64 LL;LL a[N],x,s;int main (){ //freopen("dddl.txt","
2012-12-30 21:02:23 359 1
原创 套接字学习4
很久一段时间没有回来这里了,先前的计划貌似搁浅了很长一段时间。没关系,作为菜鸟,今天晚上再从新把先前所学的捡起来!int cfd = connect(SOCKET sockfd , (SOCKADDR *)&my_addr , sizeof(SOCKADDR));1.如果建立成功返回 0,如果建立错误返回 SOCKET_ERROR;2.第一参数套接字的描述符3.第二参数套接字将要连
2012-12-27 21:11:26 247
原创 Sliding Window
/* 单调队列,从最简单的滑动窗口开始 ,这个题是纯粹的裸单调队列题目,关键在于理解单调队列的思想 */点击打开链接#include #include #include #define N 1000005using namespace std;int a[N],nt,mt;int n,m,out1[N],out2[N];int in1[N],in2[
2012-12-27 19:38:06 360
原创 字典树总结
字典树个人觉得是一种比较简单的数据结构,没什么技巧性,无非就是hash的一种变形!优点:在树的深度较低的情况下查询效率比较高;缺点:对空间要求比较高!为了便于理解贴图如下:/*下图分别存储字符串 abc,cd,defg,根节点不存储任何字符!*/个人总结一段模板如下:结构体:struct node{ int f; node *next[M]; node() { f
2012-12-26 20:13:12 537
原创 Hat’s Words
/* 很水的字典树题 */ 点击打开链接#include #include #include #include #include #define N 500000 #define M 26using namespace std;int n;char s[N][100];struct node{ int f; node *next[M];
2012-12-26 19:50:49 563
原创 拓扑排序
拓扑数据结构在图论里面应该算比较简单的数据结构了。学了很久了想写个总结,以便后面学习!对于一个DAG(有向无环图)进行一次拓扑,即将此图的所有顶点排列成一个线性序列,很明显这样的序列有很多组。便于理解如图:这张图我们可以拓扑一次得到如下线性序列:1->5->2>4>3 或者 5->1->2->4->3(每次弹出所有入度为零的节点)对于拓扑结构个人总结模板如下:int toplo
2012-12-25 20:42:24 310
原创 套接字学习3
/* 每天记住一个套接字函数 */int bind(SOCKET sockfd , struct sockaddr * name, int namelen);1.对于这个函数第一参数就是我们创建套接字返回的描述符2.第二个参数是一个结构体类型的指针 用于存储套接字的各种信息,但是我们却不要这个函数来初始化首先解释一下这个结构体 struct sockaddr:struct so
2012-12-18 23:13:55 310
原创 套接字学习2
/*每天记住一个套接字函数 */SOCKET socket(int domain , int type , int protocol); 1.对于 domain 这个参数,指的是socket的协议簇有很多种类型 AF_INET,PF_INET,,等等。其实本质是一个以定义的整数! 对于TCP/IP 一般采用 AF_INET作为参数2.对于type这个参数,也有多种类型,流式套接字(SO
2012-12-17 23:05:57 281
原创 套接字学习1
/*每天总结一个套接字函数 */第一天总结WSAStartup()函数int WSAStartup(WORD wVersionRequeted,LPWSADATA wData);首先WSAStartup的功能:加载socket库!一旦加载成功,系统就自动将socket库加载到应用程序中,然后,在编程中就可以自由的调用socket函数了。至于在windows下为什么要这样用,可能是动态链
2012-12-16 19:45:52 327
原创 Beat
/* 题目意思太模糊,其实是个超级水题,做的没什么意思,不过把以前的那种写代码的习惯稍微改了下 */思路:只要求出做出最多的题就是解,每次都从第一个题开始做,做下一个题的时间一定要大于等于上一个题的时间。(肯定存在一个最大的情况)#include #include #define N 30using namespace std;int n,res;
2012-12-14 10:19:41 457
原创 哈密顿绕行世界问题
/* 又贴一水到不得了的水题,菜到不得了,只能刷水题了,没办法。不过个人觉得这个题,考了一种数据结构,邻接表 ,不过太简单了,暴力就过了 */#include #include #include #include #define N 21#define inf 0x3f3f3f3fusing namespace std;struct node { in
2012-12-13 21:01:47 685
原创 下沙小面的(2)
/* 又加入一个水题,没有一点突破,简单题就是这样,转转又转回来了,本质上还是水题一个,没什么意思。但是我的代码确实写得没动脑筋,还是那个全排列的模板,想都没想直接套,然后就过了,以后写这样的水题,私下里还是要改进一下代码比较好 */#include #include #include #define N 31#define inf 0x3f3f3f3f
2012-12-13 19:06:11 533
原创 简单三分题
点击打开链接#include #include #define inf 0x3f3f3f#define exp 10e-6using namespace std;struct point{ double x,y;}p[10005];double Min(double a,double b){ return a>b?b:a;}double xie(point
2012-12-10 16:58:50 361
原创 关于约数问题
几天前做了一个求约数方面的题,因为数据不大采用了打表法。个人觉得这种方案,有点无耻。于是上网查找了一下求约数的方法,现在总结一下,分成如下几类:1.求出所有的质约数;2.求所有约数的和;3.求出所有约数的个数;4.求出所有质约数指数的和;求约数个人总结了一个还算比较高效的方案模板如下:/*ps:这段程序默认不求1和负数,思路:连续分解成质因数,使用贪心的法则,将质因数和对
2012-12-10 14:37:18 411
原创 友谊赛
/* 简单的二叉树模拟题,由于数据比较小,而且数的深度也很低,模拟水过,应当没有问题*//* 每位ACMer需要回答10个问题(其编号为1到10),越后面越有难度。答对的,当前分数翻倍;答错了则扣掉与题号相同的分数,(选手必须回答问题,不回答按错误处理)。每位选手都有一个起步的分数为10分。假设某位ACMer最终得分为N分,如果不让你看比赛过程,你能推断出他哪个题目答对了,哪个题目答错了吗?如
2012-12-10 13:08:19 265
原创 Super Jumping! Jumping! Jumping!
/* 又做一水题,裸递增子序列 ,先贴在这里吧 以后 再汇总的一处*/#include #include #include #define N 1005using namespace std;int a[N] , b[N];int Max (int a1,int b1){return a1>b1?a1:b1;}/*思路:裸最大递增子序列*/int main()
2012-12-09 12:51:04 258
原创 Monkey and Banana
/* 最大递增子序列模型 ,题目意思:给你很多种箱子的长宽高,求箱子所能垒成的最高高度,要求必须底层的箱子长宽覆盖上层的箱子,注意每种箱子都有无限多个(这个很重要) 最近听项目高手说不管写什么程序,一定要写点注释,所以我也学着写点,为以后打基础!*/#include #include #include #include #define N 1000using names
2012-12-08 22:41:51 255
原创 hash学习笔记
对于hash的主要思想:hash主要是以空间来换取时间,所以hash往往在时间上具有很大的优势!这里主要总结针对字符串和大数据整理几个hash常用的方法:线性探针法:对于线性探针法,主要处理一些大数据比较方便,使用线性探针可以压缩存储数据!即一段内存里面存储更多的数据。线性探针法的效率更存储空间的大少成正相关,空间越大所花时间查找效率越低!模板:struct node {
2012-12-07 23:44:29 285
原创 圆桌会议
/* 题意如下 一群人围成一圈,就交换多少次,可以反序 比如 1234 变成 4321 需要多少次(当做环形考虑),简单的数学题,一刀切成两半来考虑就可以了!切成两半之后,就可以当做线性的来考虑 也就是直接一个高斯公式可以搞定!做数学题,水平太差了,一开始还以为是个菲波拉契式,姿势差了十万八千里,哎,知道是分开考虑,却毫无逻辑的想到了菲波拉契弱爆了 ,这些简单的找规律题都成了硬伤!O
2012-12-07 19:22:11 411
原创 Assassin’s Creed(天津online)
#include #include #define N 100005using namespace std;struct node { int dao,xue;}a[N],b[N];int cmp(node x,node y){return x.xue<y.xue;}int main (){ //freopen("t.txt","r",stdin); int p,n,m,t
2012-12-07 16:51:33 412
原创 A very hard mathematic problem(天津online)
/* x^z+y^z+x*y*z=k,x1 , max(k)=2^31,k已知!求x y z的组合,k的范围很明:1点击打开链接#include #include #include #define N 1309typedef __int64 LL;using namespace std;LL POW(int x,int y){ LL s=1; for(
2012-12-07 10:19:52 411
AES核心代码
2013-07-07
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人