自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

chutzpah

生活只是一种选择,但一定要有自己的梦想

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

转载 最大流最小割定理

令N = (V, E)为一个网络(有向图)并且有s, t ∈ V 为N的源点和目标点。最大流定义: 一条边的容量是一个映射c:E→R+c : E → R^+,记做 cuv c_{uv} 或者c(u,v) c(u, v),代表着能通过这条边的最大的流量。定义: 一个流是一个映射  f:E→R+f : E → R^+,记做 fuv f_{uv} 或者 f (u,v) f (u, v)。每一条流有以下两个

2017-03-30 22:40:10 1551

原创 [POJ] - 3368 Frequent values [线段树]

DescriptionYou are given a sequence of n integers a1 , a2 , … , an in non-decreasing order. In addition to that, you are given several queries consisting of indices i and j (1 ≤ i ≤ j ≤ n). For each qu

2017-03-23 18:02:14 611

原创 [POJ] - 3264 Balanced Lineup [RMQ][ST]

For the daily milking, Farmer John’s N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows. To keep things s

2017-03-23 09:24:03 264

转载 RMQ算法

概述 RMQ(Range Minimum/Maximum Query),即区间最值查询,是指这样一个问题:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,j<=n),返回数列A中下标在i,j之间的最小/大值。这两个问题是在实际应用中经常遇到的问题,下面介绍一下解决这两种问题的比较高效的算法。当然,该问题也可以用线段树(也叫区间树)解决,算法复杂度为:O(N)~O(logN),这里我们暂

2017-03-22 22:24:41 354

原创 [POJ] 3264 Balanced Lineup [线段树]

DescriptionFor the daily milking, Farmer John’s N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows. To ke

2017-03-22 21:43:35 355

原创 [HDU] I Hate It [线段树]

I Hate It Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 71525 Accepted Submission(s): 27666Problem Description很多学校流行一种比较的习惯。老师们很喜欢询问

2017-03-22 17:22:44 280

原创 Codeforces Round #400 C. Molly's Chemicals [二分]

C. Molly’s Chemicals time limit per test2.5 seconds memory limit per test512 megabytes inputstandard input outputstandard output Molly Hooper has n different kinds of chemicals arranged in a line.

2017-03-21 22:36:59 603

原创 Gym - 100187D [逆元]

Everyone knows that the battle of Endor is just a myth fabled by George Lucas for promotion of his movie. Actually, no battle of Endor has happened and the First Galactic Empire prospers to this day.Th

2017-03-19 22:03:07 630

原创 [51NOD]1126 求递推序列的第N项 [线性递推关系与矩阵乘法]

题目链接有一个序列是这样定义的:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. 给出A,B和N,求f(n)的值。Input输入3个数:A,B,N。数字之间用空格分割。(-10000 <= A, B <= 10000, 1 <= N <= 10^9) Output 输出f(n)的值。Input示例3 -1 5Outp

2017-03-17 23:45:55 584

原创 [HPU] 机房的位置(三)[二分图最大匹配][匈牙利算法]

题目描述 还记得之前的机房位置问题吗?某天有n个学长来到机房,发现机房有m个空位。据了解,每个学长都有自己所喜欢的位置,而且他们都不愿意坐自己不喜欢的位置。现在我想知道最少会有多少个学长得不到位置。学长编号从1-n,位置编号从1-m。输入 有t组测试数据,每组数据第一行是两个整数n和m,接下来有n行,第i+1行开头是一个整数p[i],接下来跟着p[i]个整数代表第i个学长所喜欢的位置编号。(1

2017-03-16 22:06:47 414

转载 二分图最大匹配问题与匈牙利算法的核心思想

最近在学习图论相关知识,读到二分图最大匹配问题的匈牙利算法,感觉很有意思,所以记录下来。概念在假设读者已经了解图论最最基本的概念的基础上(例如:顶点、边、路径、圈),我们先来看一下二分图特有的概念定义。二分图(Bigraph, Bipartite graph)是一种特殊的图,它的顶点可以被分成两个不相交的集合(UU 和 VV),并且同属一个集合内的点两两不相连(EU=EV=∅E

2017-03-16 13:17:59 2541

原创 [POJ] 3070 Fibonacci [矩阵快速幂]

FibonacciTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 14582 Accepted: 10269DescriptionIn the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = F

2017-03-16 13:07:15 370

原创 单链表表示边权

Til the Cows Come HomeBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep,

2017-03-09 11:01:22 345

原创 [HDU] 5311 Hidden String [DFS]

Today is the 1st anniversary of BestCoder. Soda, the contest manager, gets a string ss of length nn. He wants to find three nonoverlapping substrings s[l1..r1]s[l_1..r_1], s[l2..r2]s[l_2..r_2], s[l3..r

2017-03-08 21:17:41 300

原创 计算直线的交点数 [dfs]

Description 平面上有n条直线,且无三线共点,问这些直线能有多少种不同交点数。 比如,如果n=2,则可能的交点数量为0(平行)或者1(不平行)。Input 输入数据包含多个测试实例,每个测试实例占一行,每行包含一个正整数n(n<=20),n表示直线的数量. Output 每个测试实例对应一行输出,从小到大列出所有相交方案,其中每个数为可能的交点数,每行的整数之间用一个空格隔开。S

2017-03-08 17:35:43 472

原创 斐波那契数列 通项公式 [数学]

2007年到来了。经过2006年一年的修炼,数学神童zouyu终于把0到100000000的Fibonacci数列 (f[0]=0,f[1]=1;f[i] = f[i-1]+f=2”>i-2)的值全部给背了下来。 接下来,CodeStar决定要考考他,于是每问他一个数字,他就要把答案说出来,不过有的数字太长了。所以规定超过4位的只要说出前4位就可以了,可是CodeStar自己又记不住。于是他

2017-03-08 07:58:33 1242

原创 线筛欧拉函数

Description The Euler function phi is an important kind of function in number theory, (n) represents the amount of the numbers which are smaller than n and coprime to n, and this function has a lot of

2017-03-07 18:07:22 327

原创 [poj]3187 Backward Digit Sums [dfs]

FJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N <= 10) in a certain order and then sum adjacent numbers to produce a new list with one fewer number. They re

2017-03-07 17:43:06 272

原创 [poj]1118 Lining Up [思维][数学][尺取]

Description “How am I ever going to solve this problem?” said the pilot. Indeed, the pilot was not facing an easy task. She had to drop packages at specific points scattered in a dangerous area. Furth

2017-03-07 13:15:35 372

原创 [HPU]1275: God's ladder [DP]

题目描述 天明来到神之宫殿,在他眼前出现了若干个石柱,每个石柱上有1枚金币,天明可以任意选择一个石柱开始,然后向前方的石柱瞬移,而且他所瞬移到的石柱的高度必须要大于现在所在石柱的高度。求天明所能获得的最大金币数以及任意一种可以获得这么多金币的路线(每个石柱的高度)。输入 第一行一个数n,表示石柱的个数。然后2~n+1行,每行一个石柱的高度h[i],分别是1,2,,n石柱的高度。2题解这题的“亮点

2017-03-06 11:03:52 394

原创 [51NOD] 1009 数字1的数量 [数学][详解]

给定一个十进制正整数N,写下从1开始,到N的所有正数,计算出其中出现所有1的个数。 例如:n = 12,包含了5个1。1,10,12共包含3个1,11包含2个1,总共5个1。 Input 输入N(1 <= N <= 10^9) Output 输出包含1的个数 Input示例 12 Output示例 5题解提供一组数据 输入127948输出99344 不是很好想记n的长度为LL,设

2017-03-04 20:22:45 529

原创 [51NOD]1283 最小周长[数学]

一个矩形的面积为S,已知该矩形的边长都是整数,求所有满足条件的矩形中,周长的最小值。例如:S = 24,那么有{1 24} {2 12} {3 8} {4 6}这4种矩形,其中{4 6}的周长最小,为20。 Input 输入1个数S(1 <= S <= 10^9)。 Output 输出最小周长。 Input示例 24 Output示例 20题解#include<cstdio>#in

2017-03-04 15:44:08 583

原创 [51NOD]1284-2 3 5 7的倍数 [容斥]

给出一个数N,求1至N中,有多少个数不是2 3 5 7的倍数。 例如N = 10,只有1不是2 3 5 7的倍数。 Input 输入1个数N(1 <= N <= 10^18)。 Output 输出不是2 3 5 7的倍数的数共有多少。 Input示例 10 Output示例 1题解简单的容斥题,分析看这儿》》传送门#include<cstdio>#include<string.h>

2017-03-04 14:59:11 310

原创 [HPU] 1075: KACA的数字排序 [排序][水题]

题目描述 PIPA想让KACA给一串数进行排序。KACA表示这是个简单的问题,然而当他看到这些数字后,顿时懵逼了。只见各种1234567890987654321……都是非常巨大的数字,但在他思考之后,还是选择接下了这个任务。输入 第一行是一个整数TT ( 1≤T≤1001≤T≤100 ),代表有TT组测试数据。每组数据第一行是一个整数nn ( 1≤n≤1001≤n≤100 ),代表有nn个数字。

2017-03-04 12:02:42 352

原创 Kolya and Tanya [组合数学]

Kolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the vertexes of an equilateral triangle.More formally, there are 3n gnomes

2017-03-04 10:30:48 408

原创 Asphalting Roads [水题]

City X consists of n vertical and n horizontal infinite roads, forming n × n intersections. Roads (both vertical and horizontal) are numbered from 1 to n, and the intersections are indicated by the num

2017-03-04 10:29:09 423

原创 Alena's Schedule[水题]

Description Alena has successfully passed the entrance exams to the university and is now looking forward to start studying.One two-hour lesson at the Russian university is traditionally called a pair

2017-03-04 10:27:21 263

原创 Laurenty and Shop[水题]

time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output A little boy Laurenty has been playing his favourite game Nota for quite a while and is now

2017-03-04 10:25:36 401

原创 [POJ] 3669 Meteor Shower [BFS]

DescriptionBessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her safety, she vows to find her w

2017-03-03 18:40:33 234

原创 [Aizu]-0558 Cheese [BFS]

問題今年も JOI 町のチーズ工場がチーズの生産を始め,ねずみが巣から顔を出した.JOI 町は東西南北に区画整理されていて,各区画は巣,チーズ工場,障害物,空き地のいずれかである.ねずみは巣から出発して全てのチーズ工場を訪れチーズを 1 個ずつ食べる.この町には,N 個のチーズ工場があり,どの工場も1種類のチーズだけを生産している.チーズの硬さは工場によって異なっており,硬さ 1 から N までのチ

2017-03-03 09:03:18 882

原创 [HDU] 1010 Tempter of the Bone [DFS][奇偶剪枝]

Problem Description The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He rea

2017-03-02 15:17:03 231

原创 图论算法及其模板

什么方法好,和数据关系很大,和你使用的数据结构也有关。比如使用vector,它自身就有复杂度,所以在稠密图上不及二维数组的邻接矩阵,但在稀疏图方面肯定vector的动态数组实现的链接列表更好。有些复杂度高的算法,其实际体验可能比复杂度低的更快,因为复杂度是按最糟糕的情况算的,而且复杂度低的算法往往是使用数据结构优化而实现的,而实现数据结构也是存在复杂度的,所以会出现这些个情况。

2017-03-01 22:04:37 560

原创 [poj] 1979 Red and Black [dfs]

DescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. B

2017-03-01 17:50:23 300

空空如也

空空如也

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

TA关注的人

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