自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Charlie Pan's Blog

山是山,山非山;其实困难与简单之间只是一线之隔。

  • 博客(52)
  • 收藏
  • 关注

原创 搬家

搬家至 charlie01.is-programmer.com

2014-11-18 16:21:59 789

原创 TopCoder SRM 144 DIV 2

200:Problem Statement  Computers tend to store dates and times as single numbers which represent the number of seconds or milliseconds since a particular date. Your task in this

2014-08-28 10:52:56 1015

原创 Codeforces Round #263 (Div. 1) C. Appleman and a Sheet of Paper

题目地址:http://codeforces.com/contest/461/problem/C题目大意:见原题。算法分析:启发式暴力,每次把短的纸带折到长的纸带中,在全局记一个rev标记。注意细节。Code:#include #include #define N 100000using namespace std;bool rev;int n,q,beg=1,en

2014-08-27 11:04:09 1501

原创 Codeforces Round #263 (Div.1) B. Appleman and Tree

题目地址:http://codeforces.com/contest/461/problem/B题目大意:给一棵树,每个点为白色或黑色,切断一些边,使得每个连通块有且仅有一个黑点,问划分方案数。算法讨论:TreeDP。f[x][0..1]表示x所在连通块有0/1个黑点。设y为x的儿子,则DP方程为f[x][1]=f[x][1]*f[y][0]+f[x][1]*f[y][1]+f[x][0]

2014-08-27 09:05:22 1456

原创 BZOJ 1913: [Apio2010]signaling 信号覆盖

题目地址:http://www.lydsy.com/JudgeOnline/problem.php?id=1913题目大意:

2014-08-25 16:18:50 844

原创 BZOJ 1042: [HAOI2008]硬币购物

题目地址:http://www.lydsy.com/JudgeOnline/problem.php?id=1042题目大意:4种硬币,面值分别为C1,

2014-08-25 13:35:08 765

原创 SPOJ 18393. Hamiltonian Cycles

题目地址:http://www.spoj.com/problems/IE5/题目大意:一个n个点的无向完全图,删去m条边,求哈密尔顿圈个数。(m算法讨论:对删去的边进行容斥,问题转化为强制经过m'条边的完全图的哈密尔顿回路。把强制经过的边缩成一个点,问题转化为求一个完全图的哈密尔顿圈个数(n-1)!/2。由于x->u->v->y和x->v->u->y是2个不同的圈,因此对答案的贡献要乘2,

2014-08-25 13:24:25 813

原创 SPOJ 16639. Endless Knight

题目地址:http://www.spoj.com/problems/IE4/题目大意:一张H*W的棋盘,上面有R个障碍不能经过,问从(1,1)到(H,W)往右下走马步有多少种走法,模10007。R算法讨论:首先对R个障碍容斥,强制某些障碍必须经过,那么问题转化为了从矩形的左上角走到矩形右下角(从一个障碍到一个障碍)的走法数。设a,b是矩形的长和宽,列二元一次方程x+2y=a,2x+y=b,

2014-08-25 13:16:04 842

原创 SPOJ 16637. Non-Square Free Numbers

题目地址:http://www.spoj.com/problems/IE3/题目大意:求第n个有平方数因子的数。算法讨论:        二分答案。对于答案mid,从2到sqrt(mid)枚举i,则从1~mid中含有i^2因子的数有mid/(i^2)个。        需要注意2点:1)对于完全平方数i,因子i在之前已经被统计过了,因此忽略即可。               

2014-08-25 13:01:15 1047

原创 SPOJ 16636. Journey

题目地址:http://www.spoj.com/problems/IE2/题目大意:一个n个点m条边的无向图,n个点编号为1~n,走d步,要求经过编号为1~k的点至少一次,问方案数。n算法讨论:        对必须经过的点进行容斥,强制某些点不能经过,删去和这些点相连的边,然后用矩阵乘法快速幂。        设f[i][j]表示经过j步,到达点i的方案数。转移方程为:f[i]

2014-08-25 11:52:51 683

原创 SPOJ 16607. Sweets

题目地址:http://www.spoj.com/problems/IE1/题目大意:n个盒子,每个盒子里有mi颗糖,从每个盒子里取一些糖,要求至少取a颗,至多取b颗,问方案数。n算法讨论:        对盒子进行容斥,强制某些盒子取mi+1颗糖,然后将剩余的糖分配到n+1个盒子中(因为糖可以不分完,所以多设一个盒子放剩下的糖)。        由隔板法分析可知,将n个等价的球放

2014-08-25 10:39:14 1493

原创 SPOJ 8282. Distance

题目地址:http://www.spoj.com/problems/DIST/题目大意:给n个点(xi,yi),求(x0,y0),使得最小化sigma(|xi-x0|^pi+|yi-y0|^pi)。算法讨论:因为xi和yi互不影响,因此可以分开计算。对于xi,先把xi排序,相邻2个xi之间的函数可以把绝对值去掉,这样的函数是一个一元三次函数。求一元三次函数的最值可以用导数,导数的零点就是原

2014-08-22 21:52:41 829

原创 BZOJ 1010: [HNOI2008]玩具装箱toy

题目地址:http :// www . lydsy . com / JudgeOnline / problem . php ? id = 1010题目大意:见原题。算法分析:        设s[i]为c[i]的前缀和,f[i]表示第1个物品到第i个物品的最小代价。        易得DP方程为f[i]=min(f[j]+(s[i]-s[j]+i-j+1-l)^2)。

2014-07-18 14:10:35 2148

原创 BZOJ 3531: [Sdoi2014]旅行

题目地址:http :// www . lydsy . com / JudgeOnline / problem . php ? id = 3531题目大意:见原题。算法讨论:树链剖分。对于每种宗教开一棵线段树即可。Code:#include #include #define N 3000000#define M 30000000#define oo 0x7f7f7f7f

2014-05-14 11:43:59 1675

原创 BZOJ 1036: [ZJOI2008]树的统计Count

题目地址:BZOJ 1036题目大意:给出一棵树,每个点有一个权值,要求三种操作:1.修改某个点的权值,2.询问x到y路径上各点的权值最大值,3.询问x到y路径上各点的权值之和。算法讨论:树链剖分模板题。Code:#include #include #define N 30000#define oo 0x7f7f7f7fusing namespace std;int

2014-05-12 21:01:07 1038

原创 Codeforces 5

A. Chat Server's Outgoing Traffic        题目地址:http://codeforces.com/contest/5/problem/A        题目大意:见原题。        算法讨论:用STL的string和map维护。        Code:#include #include #include #include

2014-05-12 15:37:18 858

原创 Codeforces 4

A. Watermelon        题目地址:http://codeforces.com/contest/4/problem/A        题目大意:给一个数,问它能否分解成2个偶数之和。        算法讨论:见代码。        Code:#include using namespace std;int n;int main(){ scanf("

2014-05-10 16:52:58 715

原创 UPD BZOJ 1798: [Ahoi2009]Seq 维护序列seq

原文地址:http://blog.csdn.net/charlie_pyc/article/details/19482769原文中

2014-05-10 16:34:52 664

原创 Codeforces 3

A. Shortest path of the king        题目地址:http://codeforces.com/contest/3/problem/A        题目大意:求8*8的棋盘上一个点到另一个点的最短路径。        算法讨论:优先斜着走,走到同一直线后直着走。        Code:#include #define N 10000us

2014-05-09 21:57:41 1145

原创 BZOJ 3527: [Zjoi2014]力

题目地址:http://www.lydsy.com/JudgeOnline/problem.php?id=3527题目大意:见原题。算法讨论:        设A[i]=q[i],B[i]=1/(i^2)。        设C[i]=sigma(A[j]*B[i-j]),D[i]=sigma(A[n-j-1]*B[i-j])。        那么所求的E[i]=C[i]-D

2014-05-05 16:06:12 3362

原创 Codeforces 2

A. Winner        题目地址:http://codeforces.com/contest/2/problem/A        题目大意:给出每一次比赛的得分情况,问最后得分最高的人。若最后分数相同,则输出分数相同的人中第一个分数不小于最后最高分数的人。        算法讨论:用STL中的map和set维护即可。        Code:#include #i

2014-05-04 13:03:27 1201

原创 Codeforces 1

A. Theatre Square:        题目地址:http://codeforces.com/contest/1/problem/A        题目大意:n*m的长方形用a*a的正方形覆盖,允许超出长方形,问需要几个正方形。        算法讨论:计算长和宽分别需要几个a,相乘即可。        Code:#include #include using

2014-04-30 16:23:08 713

原创 Fast Fourier Transform

/* * Fast Fourier Transform * By Pan Yuchong */#include #include #include #define maxN 1000000#define pi 3.14159265358979323846#define re real()using namespace std;int n,m,l,N,L,rev[max

2014-04-30 14:35:52 762

原创 Project Euler 46~50

Problem 46:It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square.9 = 7 + 21215 = 7 + 22221 = 3 + 23225 = 7 + 232

2014-04-25 16:26:37 813

原创 Project Euler 41~45

Problem 41:We shall say that an n-digit number is pandigital if it makes use of all the digits 1 ton exactly once. For example, 2143 is a 4-digit pandigital and is also prime.What is the lar

2014-04-24 14:00:55 2554

原创 Project Euler 36~40

Problem 36:The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.(Pleas

2014-04-23 15:59:53 708

原创 Project Euler 31~35

Project 31:In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation:1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p).It is possible to

2014-04-17 17:08:42 714

原创 Project Euler 26~30

Problem 26:A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given:1/2= 0.51/3= 0.(3)1/4

2014-04-16 16:14:35 737

原创 Project Euler 21~25

Problem 21:Let d(n) be defined as the sum of proper divisors of n (numbers less thann which divide evenly into n).If d(a) = b and d(b) = a, where a b, then a and b are an amicable pair and

2014-04-16 16:08:15 27390

原创 Project Euler 16~20

Problem 16:215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.What is the sum of the digits of the number 21000?

2014-04-16 16:00:19 580

原创 Project Euler 11~15

Problem 11:In the 2020 grid below, four numbers along a diagonal line have been marked in red.08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 0849 49 99 40 17 81 18 57 60 87 17 40 9

2014-04-16 15:54:00 916

原创 Project Euler 6~10

Problem 6:The sum of the squares of the first ten natural numbers is,12 + 22 + ... + 102 = 385The square of the sum of the first ten natural numbers is,(1 + 2 + ... + 10)2 = 552 = 3025

2014-04-14 16:53:10 756

原创 Project Euler 1~5

Problem 1:If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000.

2014-04-14 16:44:55 745

原创 BZOJ 1412: [ZJOI2009]狼和羊的故事

题目地址:http://www.lydsy.com/JudgeOnline/problem.php?id=1412题目大意:将一个矩阵中的1和2分隔,求出最小的分隔代价。算法讨论:        很明显这是一个类二分图,由于要将狼和羊分开,所以一边是狼,一边是羊。        然后求这个图的最小割。        相邻的格子之间连容量为1的边,含义是如果割这条

2014-03-15 19:22:08 1737

原创 BZOJ 2007: [Noi2010]海拔

题目地址:http://www.lydsy.com/JudgeOnline/problem.php?id=2007题目大意:见原题&算法讨论。算法讨论:        首先一个贪心的思想:每个点不是0即使1。        于是就比较显然地想到了最小割。        和BZOJ 1001一样,如果用Dinic算法和Sap算法显然是要TLE的。     

2014-03-15 19:11:37 1334

原创 BZOJ 1305: [CQOI2009]dance跳舞

题目地址:http://www.lydsy.com/JudgeOnline/problem.php?id=1305题目大意:n个男孩和n个女孩,每个人和不喜欢的异性最多跳k次舞,问最多可以跳几次舞。算法讨论:        很容易看出这题是二分图。        由于每个人可以和喜欢的异性跳任意次舞,那么一个人跳舞的最多次数为k+喜欢的异性数。        于

2014-03-15 18:49:41 828

原创 BZOJ 1001: [BeiJing2006]狼抓兔子

题目地址:http://www.lydsy.com/JudgeOnline/problem.php?id=1001题目大意:见原题&算法讨论。算法讨论:        很容易看出这是最小割。        我们首先想到的是最小割=最大流。        但是点数最多有1e6,用O(n^2*m)的Dinic和O(n*m^2)的sap显然都是要超时的。(据说Dini

2014-03-15 17:03:04 1183

原创 BZOJ 2809: [Apio2012]dispatching

题目地址:http://www.lydsy.com/JudgeOnline/problem.php?id=2809题目大意:在一棵树中,每个节点有2个权值(我们不妨称其为val1和val2)。求一个节点x,在这个节点和其子树中找一个点集S,使得Σval1(i),i∈S小于某个下界,并使得val2(x)*|s|最大。算法分析:        根据题目的大意我们可以比较显然

2014-03-09 09:19:10 1623

原创 BZOJ 2333: [SCOI2011]棘手的操作

题目地址:http://www.lydsy.com/JudgeOnline/problem.php?id=2333题目大意:对于一幅图支持7种操作(详见原题)。算法讨论:        通过U x y、F2 x和F3操作,我们发现题目既要求最大值又要支持合并操作,我们可以想到用可并堆进行维护。        可并堆?如果你愿意的话显然配对堆和Fibonacci堆是很

2014-03-09 08:57:49 2969 3

原创 BZOJ 3224: Tyvj 1728 普通平衡树

题目地址:http://www.lydsy.com/JudgeOnline/problem.php?id=3224题目大意:维护平衡树的6个操作。算法讨论:        平衡树裸题。        具体就不多说了,我用的是Treap。Code:/* * Problem:3224 * Author:PYC */ #include #inc

2014-03-06 08:49:23 1676

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除