- 博客(136)
- 资源 (1)
- 收藏
- 关注
原创 ZOJ 2314 (无源汇可行流)
#include #include #include #include #include #include using namespace std;typedef long long LL;#define V 210#define E 100000#define INF 10000000int n, m;////void init(){// nv =
2013-08-03 11:18:00
2111
转载 求两圆交点坐标
大概也可以说成是解二元二次方程组.是从...网站上copy的:The following note describes how to find the intersection point(s) between two circles on a plane, the following notation is used. The aim is to find the two
2013-07-24 22:00:20
10221
转载 二分图匹配
转自 http://endlesscount.blog.163.com/blog/static/821197872012622103810976/2012-07-23 12:58:37| 分类: 学习小结|字号 订阅 前段时间系统的学习了一下二分图匹配,收获还是蛮大的,总算是把最大匹配、点覆盖、点独立、边覆盖什么的关系搞清楚了,基本的算法和定理
2012-11-18 19:35:11
1980
原创 uva 11181 Probability|Given
递归边界没处理好,切记,。#include #include #include #include using namespace std;typedef long long lld;lld gcd(lld a, lld b){ return b == 0? a:gcd(b, a%b);} int main(){ lld p, q; w
2012-11-10 16:48:53
2061
原创 uva 10277 Boastin' Red Socks
#include #include #include #include using namespace std;typedef long long lld;lld gcd(lld a, lld b){ return b == 0? a:gcd(b, a%b);} int main(){ lld p, q; while (scanf("%lld %
2012-11-10 16:42:37
1979
原创 UVA 11027 Palindromic Permutation
#include #include #include #include #include using namespace std;int n; char str[50];char ans[50]; string half; int num[30]; int len;int mid; int cantor[16]; void init(int n){ ca
2012-11-10 16:08:08
1881
转载 acm应该注意的数据类型问题
转自http://blog.csdn.net/springwinter1/article/details/4385770其中long 和 int 范围是[-2^31,2^31),即-2147483648~2147483647。而unsigned范围是[0,2^32),即0~4294967295。也就是说,常规的32位整数只能够处理40亿以下的数。l ong long的范围是-2
2012-11-10 16:00:38
1949
原创 uva 10940 Throwing cards away II
我打印出了1 - 100 n = 1, ans = 1n = 2 ans = 2n = 3 ans = 2n = 4 ans = 4n = 5 ans = 2n = 6 ans = 4n = 7 ans = 6n = 8 ans = 8n = 9 ans = 2n = 10 ans = 4n = 11 ans = 6n = 12 ans = 8
2012-11-07 19:02:23
1751
原创 UVA 10079 Pizza Cutting
第n刀最多与 n - 1条直线相交,从而增加 n 块 Pizza.#include typedef long long lld; //归纳 int main(){ int n; while (scanf("%d", &n) == 1 && (n>=0)){ printf("%lld\n", 1LL + lld(n) * lld(n+1)
2012-11-04 22:22:25
1998
原创 uva 10564 Paths through the Hourglass
记忆化搜索。注意用 long long#include #include #include #include #include #include using namespace std;const int inf = (-1u>>1);typedef long long lld; int a[50][25];lld d[50][25][505];int n
2012-10-31 23:16:00
1683
原创 uva 10635 Prince and Princess(稀疏LCS)
nlogn#include #include #include #include #include using namespace std;#define N 100000 int a[N], b[N], c[N]; int bs(int *f, int l, int r, int nu){ while (l < r){ int m
2012-10-31 22:58:26
1776
原创 UVA 10911 Forming Quiz Teams(状态压缩DP)
#include #include #include #include using namespace std;double d[65537];int n, des;double dis[16][16];int x[16], y[16];const int inf = 100000000; double f(int i, int j){ return sq
2012-10-31 22:56:35
1717
原创 POJ 1159 Palindrome
#include #include #include #include #include using namespace std;#define N 5010int d[2][N];char s[N]; // if (i == j)m[i][j] = m[i + 1][j - 1];// else m[i][j] = min(m[i][j - 1], m[i + 1]
2012-10-31 22:51:17
1781
原创 POJ 1161 WALLS
主要难在构图上,很麻烦。用的Floyd 110ms#include #include #include #include #include #include using namespace std;#define RMAX 210int G[RMAX][RMAX];set person[30]; //每个人所相邻的区域 int personat[30]; //
2012-10-31 22:20:47
1761
原创 POJ 1661 Help Jimmy
简单的DP,利用重叠子问题,详见代码#include #include #include #include #include using namespace std;#define N 1010int d[N][2];struct stage{ int l, r, h; int lnext, rnext; stage(in
2012-10-31 22:01:44
1638
原创 ZOJ 1679 Telescope (DP)
利用重叠子问题,f [ i ][ j ][ k ] 表示 i 到j 的圆弧内的点 取 k 变形的最大面积。#include #include #include using namespace std;// 规范相交#include const double PI = 3.1415926535898; struct Point{ double x,
2012-10-31 21:32:57
1781
原创 POJ 1947 Rebuilding Roads(树状DP)
#include #include #include #include using namespace std;const int inf = 1000000; #define N 151 int d[N][N];int cld[N], bro[N];bool fa[N]; int n, p;void dfs(int s){ for (int i = 0; i
2012-10-31 21:28:32
1734
原创 poj 1691 Painting a Board(状态压缩DP)
#include #include #include #include using namespace std;struct sq{ int lx, ly, rx, ry; int col; void get(){ scanf("%d %d %d %d %d", &ly, &lx, &ry, &rx, &col);
2012-10-31 20:02:55
5313
原创 poj 1337 A Lazy Worker
这里用dp[ i ]表示时刻 i 及其之后的时间里所需工作的最少时间,那么从后向前递推即可, 一个重要条件是 di - ai #include #include #include #include #include using namespace std;vector t[300];int dp[400]; int l[300], a[300], d
2012-10-31 19:51:35
1865
转载 C语言详解sizeof
加粗的字作为注意点。原文地址:http://blog.sina.com.cn/s/blog_5da08c340100bmwu.html一、sizeof的概念 sizeof是C语言的一种单目操作符,如C语言的其他操作符++、--等。 它并不是函数。 sizeof操作符以字节形式给出了其操作数的存储大小。 操作数可以是一个表达
2012-10-26 09:10:41
591
转载 最长公共子序列O(nlogn)
转自 http://hi.baidu.com/fandywang_jlu/item/b9a9580bbadbbc1aebfe38fd最长公共子序列O(nlogn)求最长公共子序列(LCS)最最常见的算法是时间复杂度为O(n^2)的动态规划(DP)算法,这种算法在各类算法书上基本都有--DP入门典型问题!现在,介绍一种求LCS的时间复杂度为O(nlogn)的
2012-10-20 09:01:10
2433
原创 poj 3740 Easy Finding//Dancing Links 或 状态压缩Dp
对Dp还不是很熟悉,偶然看到Discuss上有人说Dp可解,我便试着实现了一下。#include #include #include using namespace std;const int inf = (-1u>>1); int n, m; #define N 16#define M 300int a[N][M]; int fbd[N];bool done[1
2012-09-07 11:31:51
526
原创 poj 3076 Sudoku //Dancing Links
#include #include #include using namespace std;const int inf = (-1u>>1); #define m 4#define n 16#define N n*n*n#define M 4*n*nchar s[20][20];struct node{ int r,c; node *L,*R,*U,*D;};nod
2012-09-07 11:18:30
484
转载 (转)(Step1-500题)UVaOJ(算法比赛入门经典+挑衅编程)+USACO
下面给出的题目有近500题,作为ACMer Training Step1,用1年到1年半时候完成。打牢根蒂根基,厚积薄发, 。 一、UVaOJ http://uva.onlinejudge.org 西班牙Valladolid大学的法度在线评测体系,是汗青最悠长、最有名的OJ。 二、《算法比赛入门经典》 刘汝佳 (UVaOJ 351道题)
2012-09-02 16:10:40
2266
转载 (转)黑书里的30道dp题
pagesectionnotitlesubmit1131.5.1例题1括号序列POJ11411161.5.1例题2棋盘分割POJ11911171.5.1例题3决斗Sicily18221171.5.1例题4“舞蹈家”怀特先生tyvj1211
2012-09-02 11:12:51
1930
转载 图的一些概念
转自http://hi.baidu.com/yy17yy/item/01599209454e9a31a2332a50独立集: 独立集是指图的顶点集的一个子集,该子集的导出子图不含边.如果一个独立集不是任何一个独立集的子集, 那么称这个独立集是一个极大独立集.一个图中包含顶点数目最多的独立集称为最大独立集。最大独立集一定是极大独立集,但是极大独立集不一定是最大的独立集。
2012-08-29 19:08:53
449
转载 如何将二维数组作为函数的参数传递
如何将二维数组作为函数的参数传递 今天写程序的时候要用到二维数组作参数传给一个函数,我发现将二维数组作参数进行传递还不是想象得那么简单里,但是最后我也解决了遇到的问题,所以这篇文章主要介绍如何处理二维数组当作参数传递的情况,希望大家不至于再在这上面浪费时间。正文: 首先,我引用了谭浩强先生编著的《C程序设计》上面的一节原文,它简要介绍了如何将二维数组作为参数传递,原文如下
2012-08-17 20:51:48
574
原创 poj 2750 Potted Flower(线段树#8)
这个题关键是这一段代码struct node{ int l, r; int lmaxs, rmaxs, maxsum; int lmins, rmins, minsum; int max, min; int sum; }Tree[N * 4];分别表示左起连续最大值,右起连续最大值,最大连续值
2012-08-16 21:17:44
502
原创 poj 3580 SuperMemo(伸展树splay)
伸展树挺复杂的,而且还有各种版本,这里找到一种教高效率的版本http://wenku.baidu.com/view/b9cc2c75a417866fb84a8ee4.html它的意思是在查找节点x的同时就自顶向下地伸展。我写不出代码,有些地方还暂时没看懂,先留着吧。这个代码是抄网上的,750ms#include #include #include using namespac
2012-08-16 20:57:18
427
原创 poj 3667 Hotel(线段树 # 7)
维护一个左起连续空房间的长度ls,右起连续空房间的长度rs,以及一个最大连续空房间数sum。注意更新子节点后,要更新父节点的cov即lazy值1032 ms#include #include #include #define L(t) t << 1 #define R(t) t << 1 | 1 //#define /2 >> 1 //影响时间效率? usi
2012-08-16 20:50:18
444
原创 poj 3468 A Simple Problem with Integers(线段树#6 / 树状数组)
线段树,维护一个add域和lazy2672ms也可以用树状数组来做:http://kenby.iteye.com/blog/962159这里给出线段树代码#include #include #include #include using namespace std;#define N 100005 typedef long long ll; struct
2012-08-16 20:34:41
435
原创 poj 2892 Tunnel Warfare(线段树#5/树状数组)
维护一个表,能够插入和删除,并且能够对某一点求前驱和后继。方法一:线段树 422ms#include #include #include #include #include #define N 50010using namespace std; stack st; int n, m; int main(){
2012-08-16 20:16:08
392
原创 poj 2352 Stars (线段树#4/树状数组)
本质上是维护一个表,每次改变一个元素的值,然后求前i个元素的和。法一:线段树 我本来是想每个叶节点表示从1到该节点位置的元素和,插入一个元素,那么它后面的节点的值都要加一,这便是操作区间。可是我这样是复杂化了,无限WA。 其实就是简单的求和问题,每个节点维护一个sum值就好了。 代码:454ms #include #include using
2012-08-16 11:43:42
479
原创 poj 2886 Who Gets the Most Candies?(线段树#3)
因为孩子们总要跳出圈子,所以计算出的要删除的索引应该是相对目前的孩子总数而言的,这里用Delete函数删除并返回删除的那个孩子的初始标号。还有关于一个整数的约数的个数的的问题,这里我采用了打表的方法。1750ms#include #include #include #include using namespace std;#define N 500005 int
2012-08-16 11:29:08
464
原创 poj 3277 City Horizon(线段树#2----离散化)
需要离散化数据;219ms#include #include #include #include using namespace std;#define N 100010typedef long long ll; struct node{ int l, r; int height; }Tree[N * 5];///
2012-08-16 11:16:35
417
原创 POJ 2777 Count Color(线段树#1)
第一次了解到线段树的lazy思想422ms#include #include using namespace std;#define N 100010struct node{ int l, r; int col; int lazy;//延迟标记 }Tree[N * 4];///int L, T, O;void b
2012-08-16 10:57:43
376
转载 国家集训队论文分类
组合数学计数与统计2001 - 符文杰:《Pólya原理及其应用》2003 - 许智磊:《浅谈补集转化思想在统计问题中的应用》2007 - 周冬:《生成树的计数及其应用》2008 - 陈瑜希《Pólya计数法的应用》数位问题2009 - 高逸涵《数位计数问题解法研究》2009 - 刘聪《浅谈数位类统计问题》动态统计
2012-08-09 20:47:00
3125
原创 POJ 2236 Wireless Network(并查集)
简单的并查集, 不过真佩服那些几十毫秒AC的。我用了1000ms+ #include #include #include #include using namespace std;#define N 1009struct POINT{ int x, y;}; int p[N];POINT a[N];vector adj[N];bool good[N]
2012-08-09 20:38:24
525
原创 POJ 1733 Parity game
黑书上的题,刚开始看不会,找结题报告,网上一大堆用什么异或思想,完全把问题复杂化,纠结了一下午加一个晚上,最后终于找到一种好理解的思想,如果i, j 间的1个数为偶数, 那么1 ~ i - 1, 和 1 ~ j的1的个数的奇偶性是相同的,否则相反,此外如果某个判断的两个端点含有以前未出现的端点,那么这两个端点间的奇偶性是无法断定的。问题退化到了分组的问题,简单的并查集就可以解决。此外还有用ha
2012-08-09 20:34:18
430
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人