随笔分类 - DP
摘要:We consider problems concerning the number of ways in which a number can be written as a sum. If the order of the terms in the sum is taken into accou
阅读全文
摘要:Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote t
阅读全文
摘要:As Gerald, Alexander, Sergey and Gennady are already busy with the usual New Year chores, Edward hastily decorates the New Year Tree. And any decent N
阅读全文
摘要:Sereja is interested in intervals of numbers, so he has prepared a problem about intervals for you. An interval of numbers is a pair of integers [l, r
阅读全文
摘要:题意:N,K,L,以及给定长度为N的序列,表示其对应的颜色,-1表示还没有涂色,现在让你去涂色,使得最后没有大于等于L的连续的同色的情况。 思路:我们用dp[i][j]表示第i个位置颜色为j的合法方案数,用sum[i]表示dp[i][1]+dp[i][2]+...dp[i][k]。 那么a[i]==
阅读全文
摘要:2121: 字符串游戏 Description BX正在进行一个字符串游戏,他手上有一个字符串L,以及其他一些字符串的集合S,然后他可以进行以下操作:对 于一个在集合S中的字符串p,如果p在L中出现,BX就可以选择是否将其删除,如果删除,则将删除后L分裂成的左右 两部分合并。举个例子,L='abcd
阅读全文
摘要:You are given two integers l l and r r (l≤r l≤r ). Your task is to calculate the sum of numbers from l l to r r (including l l and r r ) such that eac
阅读全文
摘要:You are a given a list of integers a 1 ,a 2 ,…,a n a1,a2,…,an and s s of its segments [l j ;r j ] [lj;rj] (where 1≤l j ≤r j ≤n 1≤lj≤rj≤n ). You need t
阅读全文
摘要:3297: [USACO2011 Open]forgot Description 发生了这么多,贝茜已经忘记了她cowtube密码。然而,她记得一些有用的信息。首先,她记得她的密码(记为变 量P)长度为L(1 <= L<=1,000)字符串,并可以被分成 一个或多个词(不一定是唯一的),词来自于字典
阅读全文
摘要:4033: [HAOI2015]树上染色 Description 有一棵点数为N的树,树边有边权。给你一个在0~N之内的正整数K,你要在这棵树中选择K个点,将其染成黑色,并 将其他的N-K个点染成白色。将所有点染色后,你会获得黑点两两之间的距离加上白点两两之间距离的和的收益。 问收益最大值是多少。
阅读全文
摘要:A palindromic number or numeral palindrome is a 'symmetrical' number like 16461 that remains the same when its digits are reversed. In this problem yo
阅读全文
摘要:4550: 小奇的博弈 Description 这个游戏是在一个1*n的棋盘上进行的,棋盘上有k个棋子,一半是黑色,一半是白色。最左边是白色棋子,最右边 是黑色棋子,相邻的棋子颜色不同。 小奇可以移动白色棋子,提比可以移动黑色的棋子,它们每次操作可以移动1到d个棋子。每当移动某一个棋子时, 这个棋子
阅读全文
摘要:4831: [Lydsy1704月赛]序列操作 Description 给定一个长度为 n 的非负整数序列 a_1,a_2,...a_n 。你可以使用一种操作:选择在序列中连续的两个正整数, 并使它们分别减一。当你不能继续操作时游戏结束,而你的得分等于你使用的操作次数。你的任务是计算可能的最小 得分
阅读全文
摘要:5196: [Usaco2018 Feb]Taming the Herd Description 一大清早,Farmer John就被木材破裂的声音吵醒了。是这些奶牛们干的,她们又逃出牛棚了!Farmer John已经厌 烦了奶牛在清晨出逃,他觉得受够了:是时候采取强硬措施了。他在牛棚的墙上钉了一个
阅读全文
摘要:5281: [Usaco2018 Open]Talent Show Description FarmerJohn要带着他的N头奶牛,方便起见编号为1…N,到农业展览会上去,参加每年的达牛秀!他的第i头奶牛重 量为wi,才艺水平为ti,两者都是整数。在到达时,FarmerJohn就被今年达牛秀的新规则
阅读全文
摘要:Description 从前有棵树。 找出K个点A1,A2,…,Ak。 使得∑dis(AiAi+1),(1<=i<=K-1)最小。 从前有棵树。 找出K个点A1,A2,…,Ak。 使得∑dis(AiAi+1),(1<=i<=K-1)最小。 Input 第一行两个正整数n,k,表示数的顶点数和需要选出
阅读全文
摘要:Description 魔法师小Q拥有n个宝石,每个宝石的魔力依次为w_1,w_2,...,w_n。他想把这些宝石镶嵌到自己的法杖上,来提升 法杖的威力。不幸的是,小Q的法杖上宝石镶嵌栏太少了,他必须扔掉k个宝石才能将剩下的宝石镶嵌上去。法杖的 威力等于镶嵌在上面的所有宝石的魔力按位做或(OR)运算
阅读全文
摘要:题意:长度为n的排列,m次交换xi, yi,每个交换x,y有50%的概率不发生,问逆序数的期望 。n, m <= 1000 思路:我们只用维护大小关系,dp[i][j]表示位置i的数比位置j的数大的概率。 那么每次交换x和y。 假设x<y,那么区间就有三种: [1,x-1],[x+1,y-1], [
阅读全文
摘要:Collecting one's own plants for use as herbal medicines is perhaps one of the most self-empowering things a person can do, as it implies that they hav
阅读全文
摘要:题意:给出,三个函数,h,b,a,然后T次询问,每次给出n,求sqrt(an); 思路:不会推,但是感觉a应该是线性的,这个时候我们就可以用BM线性递推,自己求出前几项,然后放到模板里,就可以求了。 数据范围在1e15,1000组都可以秒过。 ( 那么主要的问题就是得确保是线性的,而且得求出前几项。
阅读全文

浙公网安备 33010602011771号