- 博客(116)
- 资源 (9)
- 收藏
- 关注
转载 各种字符串Hash函数比较
常用的字符串Hash函数还有ELFHash,APHash等等,都是十分简单有效的方法。这些函数使用位运算使得每一个字符都对最后的函数值产生影响。另外还有以MD5和SHA1为代表的杂凑函数,这些函数几乎不可能找到碰撞。常用字符串哈希函数有BKDRHash,APHash,DJBHash,JSHash,RSHash,SDBMHash,PJWHash,ELFHash等等。对于以上几种哈希函数,我对
2012-09-26 10:12:51 571
转载 PKU 图论分类-Author McFn
打星号的表示个人认为比较经典,或是算法,构图比较好的题目1062* 昂贵的聘礼 枚举等级限制+dijkstra1087* A Plug for UNIX 2分匹配1094 Sorting It All Out floyd 或 拓扑1112* Team Them Up! 2分图染色+DP1125 Stockbroker Grapevine FLOYD1135
2012-09-26 09:45:12 2091
转载 一些图论、网络流入门题总结、汇总
一些图论、网络流入门题总结、汇总2008-09-03 11:43最短路问题此类问题类型不多,变形较少POJ 2449 Remmarguts' Date(中等)http://acm.pku.edu.cn/JudgeOnline/problem?id=2449题意:经典问题:K短路解法:dijkstra+A*(rec),方法很多相关:ht
2012-09-26 09:43:10 892
原创 HDU 1086 计算几何 求线段交点(吉大模板)
模板直接解决。。#include#include #include using namespace std;const double eps=1e-10;struct point { double x, y; };double min(double a, double b) { return a < b ? a : b; }double max(double a, double
2012-09-24 19:12:13 1159
原创 HDU 1084 类似acm计分
题意:解出0-5题得分区间不同。在解题相同的同学中,分数在该解题数前一半的同学加5分。排序即可#include#include #include using namespace std;const int N = 110;int a[N], flag[6];typedef struct{ int num, index; //char str[10]; string str
2012-09-24 18:41:01 1112
原创 HDU 1083 二分匹配
题目大意:有n个学生,p门课程,一个学生可以选修多门课程,现在要为这p门课程分别选一个课代表,且一个学生只能当一个科目的课代表,问是否能满足所有课程都找到课代表。运用常用模板:#include using namespace std;const int N = 310;int map[N][N], flag[N];int pre[N];int n, m, num;int
2012-09-24 15:54:03 1363
转载 HDU 1079 博弈
转载请注明出处,谢谢 http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlove题目:每次可以后移一个月,或者后移一天,谁先到达2001年11月4日就赢了http://acm.hdu.edu.cn/showproblem.php?pid=1079找规律,不然是月份加一,还是日期加一,
2012-09-24 15:15:45 1206
原创 HDU 1082 矩阵乘法次数计算 写了半天搞定,很有成就感啊
这个思想本来不难,实现起来感觉有点复杂,容易出错。调试了搞定。有成就感。、#include #include #include #include using namespace std;int row[26], col[26];char str[10000];int count(int *a, int n){ int flag = 0; if(n == 2) retur
2012-09-24 15:05:09 1340
原创 HDU 1077 枚举圆心, 数学
从所有点中依次取两点,然后判断到两点m, n距离为半径1的点centre(易知center在m, n连线的中垂线上)。然后判断其余有多少点在以centre为圆心的圆内,记作ans,最后找出最大的ans,就是要求的值。#include #include const double eps=1e-6;const int MAXN=305;struct point{ double x,y;
2012-09-23 20:27:35 1552 1
原创 HDU 1073 Online Judge strcat的使用,以及回车换行符的替换
#include#define N 10000char str1[N],str2[N];void input(char *str){ char tmp[N]; getchar(); gets(tmp); while(gets(tmp) && strcmp(tmp,"END")) { if(strlen(tmp)==0)
2012-09-23 19:32:31 1476
原创 HDU 1068 最大独立数(最大独立数 = 顶点数 - 最大匹配数/2)
题目大意:有n个学生,有些学生可以配对(当然是一男一女),有些不可以,相当于如果一男一女可以配对就让他们成为一组,配对不成功的就自己一组,要求最小的组数。所以 就是一个最大独立数的问题了最大独立数 = 顶点数 - 最大匹配数/2采用邻接表#include #include #include using namespace std;bool v[5
2012-09-23 18:57:17 932
原创 HDU 1066 阶乘最后非零位 应用acm模板
模板的第一程序,直接应用。#include #include #define maxn 10001 const int mod[20]={1,1,2,6,4,2,2,4,2,8,4,4,8,4,6,8,8,6,8,2}; int lastdigit(char buf[]) { int len=strlen(buf),a[maxn],i,c,ret=1; if(
2012-09-22 19:49:13 1766 1
原创 HDU 1065 PI = 3.1415926
PI设置为3.1415927 WA了一次!#include #include using namespace std;const double PI = 3.1415926;int main(){ int t; cin >> t; for(int i = 1; i <= t; i++) { double x, y; cin >> x >> y; double d
2012-09-22 19:16:12 1344
原创 HDU 1062 逆转字符串。 换行符判断使用 str[i] == '\0'
使用reverse函数, 换行符判断使用 str[i] == '\0'。#include #include using namespace std;char str[1010];int main(){ int t; cin >> t; getchar(); while(t--) { int t = 0; while(gets(str)) { int n =
2012-09-22 10:16:25 1230
原创 HDU 1061 N ^ N 的个位数
最原始的方法超时,Wa了几次,原因是 0^0 = 0 ?#include using namespace std;int main(){ int t; cin >> t; while(t--) { int n; cin >> n; int a = n % 10; int b = a; int mod = 0; for(int i = 1; i < n
2012-09-22 09:46:14 3216
原创 HDU 1060 求N ^ N 的第一位数字 用log 降低位数
m=n^n;两边同取对数,得到,log10(m)=n*log10(n);再得到,m=10^(n*log10(n));然后,对于10的整数次幂,第一位是1,所以,第一位数取决于n*log10(n)的小数部分总之,log很强大啊,在求一个数的位数上,在将大整数化成范围内的整数上,在指数问题上#include #include using namespace std;int
2012-09-22 09:10:53 1779
原创 HDU 1057 题目很难懂。300题大关
#include using namespace std;const int Dir[][2]={{-1,0},{1,0},{0,-1},{0,1}};const char density[]=".!X#";int D[16];int Map[20][20],tmp[20][20];int main(){ int T,day,i,j,k,d,x,y,index; cin>>T;
2012-09-21 15:48:02 1378
原创 HDU 1056 叠木块 程序效率低,怎么优化?
#include using namespace std;int main(){ double a[300]; a[0] = 0; for(int i = 1; i < 300; i++) { a[i] = a[i-1] + 1.0 /(i + 1); } double len; while(cin >> len, len) { int cnt = 0; for(
2012-09-21 15:22:51 755
原创 HDU 1052 田忌赛马 顺序不定时,采用循环输入
#include #include using namespace std;int a[2010], b[1010]; //a数组开成1010导致WA了一次bool cmp(int x, int y){ return x > y;}int main(){ int n; while(cin >> n, n) { for(int i = 0; i < n; i++)
2012-09-21 10:06:47 932
原创 HDU 1051 与1257类似 二维排序,然后贪心
#include #include #include #include using namespace std; typedef struct{ int x, y;} node;bool cmp(node n1, node n2){ if(n1.x != n2.x) return (n1.x < n2.x); else return (n1.y
2012-09-21 09:18:46 652
原创 HDU 1050 搬桌子 很巧妙的想法
刚开始以为是最长上升子序列的加强版,有点棘手。网上参考了http://blog.csdn.net/q3498233/article/details/5308561很巧妙!解题思路:这道题最少花多少时间,实际上我们只要考虑哪一段重合度最高,重合度最高的地方,也就是我们至少要移动的次数了。因为有400间房间,1-2对应一段走廊,3-4对应一段走廊,如此我们可以把走廊分成200段,标记为a[
2012-09-20 18:10:18 866
原创 HDU 1049
#include using namespace std;int main(){ int n; int a, b; while(cin >> n >> a >> b, n) { int t = 0; while(n > 0) { if((t & 1) == 0) n -= a; else n += b; t++; } cout <
2012-09-20 17:08:49 640
原创 HDU 1048 map
#include #include #include using namespace std;char str[210];int main(){ char b[26] = {'V', 'W','X', 'Y', 'Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q
2012-09-20 16:57:39 750
原创 HDU 1047 使用大数模板,轻松AC
#include #include using namespace std; string add(string s1,string s2){ //大数 s1 + s2 if(s1.length()<s2.length()){ string temp=s1; s1=s2; s2=temp; } for(int i=s1.length()-1,j
2012-09-20 16:37:46 607
原创 HDU 1046 数学规律题
#include#include#define p sqrt(2.0)int main(){ int t,n,m,min,max,v=1; scanf("%d",&t); while(t--&&scanf("%d %d",&n,&m)) { min=n<m?n:m; max=n<m?m:n; printf("Scenario #%d:\n",v++); if(!(m
2012-09-20 16:28:13 811
原创 HDU 1044 BFS + DFS
分别用dfs, bfs做了一次dfs超时,bfs超内存题目意思 求解是否能够到达出口 如果能 求解到达时的最大携带价值首先使用广搜搜出包括起点和终点在内 所有特殊点之间的最短距离 建立一个隐式图然后使用DFS枚举各个组合 然后求出最大值 注意DFS的强剪代码思想很好,但是代码风格让人看起来难受,改了半天还是这个样子,下次重写。#include #in
2012-09-20 16:12:39 1111
原创 HDU 1042 与1050类似,每个整形保存几位,然后整个拼凑起来
用大数模板,加法转乘法超时了,然后用二进制压缩又失败了。。最后用与1250类似的办法拼凑#include using namespace std; int num[8000]; int main() { int i , j, n, t , carry; while(scanf("%d", &n)!= EOF) {
2012-09-19 20:56:19 626
原创 HDU 1041 递推 + 大数模板
递推:0->10 ; 1->01; 00->1010; 10->0110; 01->1001; 11->0101;假设a[i]表示第i 步时候的00的个数,由上面的可以看到,00是由01 得到的,所以只要知道a[i-1]的01的个数就能够知道a[i]的00的个数了,那a[i-1]怎么求呢,
2012-09-19 17:25:12 1811
原创 HDU 1015 dfs回溯
有用六重循环的,无敌了。。。以下代码采用回溯法。#include #include #include #include using namespace std;bool visit[30] ,judge;int ans[6] ,N[26] ,total;long long target ,sum;void set(char *a){ int i ,len; for(i
2012-09-19 16:53:48 2021
原创 HDU 1036
#include int main() { int i,n,sum,h,m,s,flag,t; char str[500]; float d; scanf("%d%f",&n,&d); while(~scanf("%d",&t)) { flag=1,sum=0; for(i=0;i<n&&flag;i++) { if(s
2012-09-19 16:30:45 910
原创 HDU 1033 Edge 旋转
题目就是说当输入A时,顺时针旋转,输入V时,逆时针旋转,很简单。#include using namespace std;const int N = 205; struct point{ int x, y; point(int x = 0, int y = 0): x(x), y(y) {}};char in[N]; void solve(){ point st(300,
2012-09-19 10:56:36 1258
原创 HDU 1025 高效最长上升子序列(二分查)
用到了LIS(Longest Increasing Subsequence)最长上升(不下降)子序列,它有两种算法复杂度为O(n*logn)和O(n^2)。前者使用二分查找,后者朴素查找。它的算法大致思路:设置两个a,b数组,a数组存储数据,b数组存储最长不降序序列。此算法关键在于设计二分查找。刚开始用到了朴素dp算法,果断超时,超时代码为: #include #include usi
2012-09-19 10:41:07 1424 3
原创 HDU 1560 DNA sequence hh大神代码
#include "stdio.h"#include "string"#define M 1679616+100000struct H{ int st; int len;}q[M];int hash[M],cas =1;int n , end ,len;char str[8][8];char ku[] ="ACGT";int bfs() { int head,tail,i,
2012-09-18 15:33:25 1386 1
转载 HDU 2473 并查集加速 good
想了几中办法,甚至加入了后继结点,但是一直超时,最后参考了网上代码。原文地址:http://www.cppblog.com/MiYu/archive/2010/08/26/124771.html题目分析: 题目的意思大概就是 有N 封邮件, 编号 0 -> N-1, 然后有2种操作, M : 合并操作, 将 2 种邮件合并为一种.
2012-09-18 11:27:03 771
原创 HDU 1200 扭曲的题意
题意:把一串字符竖着写成n列,得到一张表。现在横着把表的每行拼成一个字符串,其中奇数行(从0开始)反着拼。给你这个字符串求原来的加密前的字符串。#include #include #include using namespace std;string words[21];int main (){ string str; int col; while (
2012-09-18 08:54:22 465
原创 HDU 1982 反例
没有考虑完全,WA了一次,用-----######---##-#-#(应该输出十个空格)这个例子可以验证代码的正确性。#include using namespace std;char str[10010];int main(){ int t; cin >> t; getchar(); while(t--) { gets(str); int n = strlen(st
2012-09-18 00:14:12 764
原创 HDU 1164 分解成素数乘积的形式
#include using namespace std;int a[20];int getPrimeNum(int x){ int cnt = 0; for(int i = 2; i <= x; i++) { while(x % i == 0) { a[cnt++] = i; x = x / i; } } return cnt;}int main
2012-09-17 23:34:05 717
原创 HDU 1202
WA了一次,没有注意到学分可以是小数。。#include using namespace std;int main(){ int n; while(cin >> n) { double a, b; double suma = 0, sumb = 0; while(n--) { cin >> a >> b; if(b != -1) { su
2012-09-17 23:13:35 1565
原创 HDU 1201 闰年
本来不想做这种题的,硬着头皮做了,1A#include using namespace std;bool isRun(int x){ if(x %4 == 0 && (x % 100 != 0 || x %400 == 0)) return true; return false;}int main(){ int t; cin >> t; while(t--)
2012-09-17 18:46:55 596
转载 HDU 1715 使用大数模板
#include #include using namespace std;string Add(string fNum,string sNum){ if( fNum.length() < sNum.length() ) fNum.swap(sNum); string A = "0"; A += fNum; for ( int i=1;i<=fNum.length();i++)
2012-09-17 18:32:18 718
计算机视觉:一种现代方法(第二版)清晰文字版(英文版)
2013-03-14
线性规划与网络流题解
2012-09-26
OpenCV 2 Computer Vision Application Programming Cookbook 全
2012-06-01
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人