洛谷P3531 [POI2012]LIT-Letters】的更多相关文章

题目描述 Little Johnny has a very long surname. Yet he is not the only such person in his milieu. As it turns out, one of his friends from kindergarten, Mary, has a surname of the same length, though different from Johnny's. Moreover, their surnames cont…
P3539 [POI2012]ROZ-Fibonacci Representation 题意:给一个数,问最少可以用几个斐波那契数加加减减凑出来 多组数据10 数据范围1e17 第一次瞬间yy出做法,直接上去艹了. 写完了交了对了开始想证明 策略:对于一个数\(k\),有两种可能 存在一个\(f[i]==k\) 直接返回即可 存在\(f[i]<k<f[i+1]\),这时候使用\(|k-f[i]|\)与\(|f[i+1]-k|\)的较小者所代表的\(f[i]\),然后分治处理 感性证明:这样规模…
题目传送门 A Horrible Poem 题目描述 Bytie boy has to learn a fragment of a certain poem by heart. The poem, following the best lines of modern art, is a long string consisting of lowercase English alphabet letters only. Obviously, it sounds horrible, but that…
P3533 [POI2012]RAN-Rendezvous 题目描述 Byteasar is a ranger who works in the Arrow Cave - a famous rendezvous destination among lovers. The cave consists of nn chambers connected with one-way corridors. In each chamber exactly one outgoing corridor is ma…
题面戳这 化下题面给的式子: \(z_u+z_v=p_u+p_v-b_{u,v}\) 发现\(p_u+p_v-b_{u,v}\)是确定的,所以只要确定了一个点\(i\)的权值\(x_i\),和它在同一个联通块的所有点\(j\)的权值\(x_j\)都确定下来了,并且那些点的权值都可以用\((k_jz_i+b_j(k_j\in \{-1,1\})\)来表示.因此一个联通块的答案\(ans\)为:\[z_i\Sigma {k_j}+\Sigma{b_j}\] 然后因为限制了\(0\le z_j \le…
题目传送门 转载自:five20,转载请注明出处 本来看到这题,蒟蒻是真心没有把握的,还是five20大佬巨orz 首先由于斐波拉契数的前两项是1,1 ,所以易得对于任何整数必能写成多个斐波拉契数加减的形式. 对于一个数x ,我们贪心找到与x 差值最小的斐波拉契数,将新的x 赋为差值,每次进行这个操作,统计次数,直到x 为0 为止,输出次数. 证明上述过程也很简单:由于我们知道任何整数必能写成多个斐波拉契数加减的形式,所以我们显然使xx 每次变得越小越好(即减的越多越好),因为每个斐波拉契数都等…
传送门 蠢了……还以为背包只能用来维护方案数呢……没想到背包这么神奇…… 我们用$dp[i]$表示当$c$的和为$i$时,所有的方案中使得最小的$b$最大时最小的$b$是多少 然后把所有的点按照$a$排序,询问按照$m$排序 然后跑一遍背包,如果$dp[q[i].k]>q[i].s+q[i].m$,即存在方案使得$c$的和为$q[i].k$且所有的$b$都大于$q[i].s+q[i].m$,那么这个询问就是可行的 但这个时间复杂度……我实在不明白为什么它能跑出来……而且好像还很快的样子……明明理…
题目 二分好题 首先用二分找最小的绝对值差,对于每个a[i]都两个方向扫一遍,先都改成差满足的形式,然后再找a[k]等于0的情况,发现如果a[k]要变成0,则从他到左右两个方向上必会有两个连续的区间也随之变化, 然后我们有一点K, 使K点=0时,可以分别向左和右影响区间的值.并且影响之后的值一定互为以0为首项,绝对值差为公差的等差数列. 如在在一段范围内K点影响到的值,以后的点一定不会受到影响,然后修改的次数就是该范围的面积,可以用该区间的值的和减去影响影响范围的等差数列.最后用双指针法求出每个…
Problem: 洛谷3546 Analysis: I gave up and saw other's solution when I had nearly thought of the method ... What a pity Let's define a border of string \(s\) as a prefix \(p\) of \(s\) that \(p\) is also a suffix of \(s\), and \(p\) is not longer than h…
题目传送门 MEG 题目描述 Byteotia has been eventually touched by globalisation, and so has Byteasar the Postman, who once roamedthe country lanes amidst sleepy hamlets and who now dashes down the motorways. But it is those strolls inthe days of yore that he re…