
思维
文章平均质量分 76
c_cl
这个作者很懒,什么都没留下…
展开
-
cf1148f 构造
https://blog.youkuaiyun.com/lixuanjing2016/article/details/90756240#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <string>#include &...转载 2019-08-03 18:17:43 · 234 阅读 · 0 评论 -
Codeforces Round #376 (Div. 2) F. Video Cards(前缀和)
题目链接F. Video Cardstime limit per test 1 secondmemory limit per test 256 megabytesinput standard inputoutput standard outputLittle Vlad is fond of popular computer game Bota-2. Recently, the deve...转载 2018-10-23 00:28:40 · 165 阅读 · 0 评论 -
codeforces 718E. Matvey's Birthday
题目链接:http://codeforces.com/contest/718/problem/E题目大意:给定一个长度为n的只包含a~h的字符串s,对于1<=a,b<=n,,如果|a-b|=1或s[a]=s[b],就在a与b之间连一条无向边,求这个图的直径以及有多少对点的距离(这里指最短距离)等于这个直径。直径即一个图中距离最大的两个点之间的距离。数据范围:2<=n<=10...转载 2018-10-05 00:50:00 · 137 阅读 · 0 评论 -
CodeForces 689D Friends and Subsequences (RMQ+二分)
题面: D. Friends and Subsequencestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMike and !Mike are old childhood rivals, they...原创 2018-07-20 18:56:30 · 163 阅读 · 0 评论 -
Codeforces Round #363 (Div. 1) C LRU 概率dp
法一(cf上的题解):把问题倒过来想。假设从最晚访问的元素开始向前加元素,加到k个为止。求第i个出现的概率。这样就不同考虑从缓存区有文件出来了。 将20个元素压位,dp[mask]记录mask状态(由 0/1 表示的状态)出现的可能性。当1<< i在mask中为0,也就是第i个元素没有出现过时,dp[mask]可以转移到dp[mask+(1<< i)],表示第i个元素在...转载 2018-07-25 21:33:42 · 145 阅读 · 0 评论 -
Codeforces 679C Bear and Square Grid(枚举 标记)
给你n∗n的矩阵里面有.和X,然后你可以把一块k∗k的全部变成. 问你一个连通块里最多有多少个. 看着不太难的题,但是不太好搞 首先是dfs预处理每个连通块里的.的个数 然后是n2的枚举k∗k的那块,对于k∗k这块,肯定都是.,然后就是枚举(k+2)∗(k+2)的这块的四周 去掉4个角,因为这四周和k∗k的相邻,然后看有多少个连通块,个数加进去 最后扣掉在内部的 思路感觉不难,但是不是很好实现,...转载 2018-05-31 23:38:57 · 167 阅读 · 0 评论 -
CodeForces 639E
CodeForces 639E Bear and Paradox题目描述:你现在在打一场比赛,一共有 NN 道题,为了完成第 ii 道题你需要连续花费 titi 分钟的时间。令 T=∑itiT=∑iti ,那么在第 xx 分钟结束时完成第 ii 道题将会使你获得 pi⋅(1−c⋅xT)pi⋅(1−c⋅xT) ,其中 c∈[0,1]c∈[0,1] 是一个实数常量。在任何情况下转载 2018-04-06 22:55:07 · 199 阅读 · 0 评论 -
Codeforces 639C Bear and Polynomials 【思维】
题目链接:Codeforces 639C Bear and PolynomialsC. Bear and Polynomials time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Limak is a litt转载 2018-04-05 22:42:19 · 168 阅读 · 0 评论 -
codeforces 632F. Magic Matrix
You're given a matrix A of size n × n.Let's call the matrix with nonnegative elements magic if it is symmetric (so aij = aji), aii = 0 and aij ≤ max(aik, ajk) for all triples i, j, k. Note that转载 2018-03-30 22:05:51 · 152 阅读 · 0 评论 -
codeforces 626E. Simple Skewness 三分
给n个数, 让你去掉一些数, 使得剩下的数的平均值-中位数的差值最大。 先将数组排序, 然后枚举每一个数作为中位数的情况, 对于每个枚举的数, 三分它的左右区间长度找到一个平均值最大的情况, 平均值最大, 肯定是它左边的数是靠近他的那几个数, 右边的数是最右边的那几个数。 然后所有情况取最大值。三分的写法lmid = (l*2+r)/2, rmid = (l+r*2+2)/3, 学到了转载 2018-03-18 17:40:16 · 232 阅读 · 0 评论 -
Codeforces Round #337 (Div. 2) C. Harmony Analysis 数学
Codeforces Round #337 (Div. 2) C. Harmony Analysis 数学C. Harmony Analysis The semester is already ending, so Danil made an effort and decided to visit a lesson on harmon转载 2018-01-20 11:06:22 · 150 阅读 · 0 评论 -
cf 602/problem/D Lipshitz Sequence
Description 根据利普希茨条件定义一个长度为n的序列h的L(h)值: nn>=2,(1<=i< j现给出一长度为n的序列a,给出q次查询,每次查询给出一个区间[l,r],求序列s={a[l],…,a[r]}的所有子序列L值之和 Input 第一行为两个整数n和q表示序列长度和查询次数,第二行n个整数ai表示这个序列,之后q行每行两个整数l和r表示查询区间(2转载 2017-12-21 13:23:51 · 216 阅读 · 0 评论 -
OO’s Sequence
Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number of i (li) satisfy ai mod aj=0,now OO want to know ∑i=1n∑j=inf(i,j) mod (109+7).转载 2017-09-21 16:51:49 · 223 阅读 · 0 评论 -
Codeforces Round #295 (Div. 1) C. Pluses everywhere
Codeforces Round #295 (Div. 1) C. Pluses everywhere题目大意: 你有一个长度为n的'0-9'串,你要在其中加入k个'+'号,每种方案就会形成一个算式,算式算出来的值记做这次方案的贡献。 问:所有方案的贡献,对1e9+7取模。 n,k 首先我和zzd先探讨了一会儿暴力一点的做法,唔,非常好弄的是k*n^2,枚举子转载 2017-09-21 15:48:29 · 207 阅读 · 0 评论 -
Codeforces 520D. Cubes 贪心模拟
每一步都取当前稳定的格子里面数字最大或者最小的数.用一个set维护当前可取的格子 *begin 最大 *(--end) 最小每删除一个格子都要对这个格子周围的6个格子进行稳定性检查一个格子上面的3个格子确定了这个格子的稳定性D. Cubestime limit per test 3 secondsmemory转载 2017-09-21 10:04:52 · 360 阅读 · 0 评论 -
CodeForces 733 E.Sleep in Class
Description n层楼,每层有一个指示牌指示当前是上一层还是下一层,每经过一层指示牌就会反向,对于一个起点i,最后要经过多少步才能到第0层或者第n+1层,对于每个i输出结果 Input 第一行一整数n表示楼层数,之后一个长度为n的字符串表示初始状态每层的指示方向(1<=n<=1e6) Output 输出n个整数,第i个整数表示初始时在第i层时要经过多少步才能出去,如果...原创 2018-10-25 21:50:07 · 276 阅读 · 0 评论 -
D. 80-th Level Archeology 区间扫描
Archeologists have found a secret pass in the dungeon of one of the pyramids of Cycleland. To enter the treasury they have to open an unusual lock on the door. The lock consists of n words, each consi...原创 2018-10-23 21:24:05 · 195 阅读 · 0 评论 -
B. Bitwise Formula
B. Bitwise FormulaBob recently read about bitwise operations used in computers: AND, OR and XOR. He have studied their properties and invented a new game.Initially, Bob chooses integer m, bit dept...原创 2018-11-21 10:00:59 · 222 阅读 · 0 评论 -
cf1017d 状压预处理
题意:给你n m q,表示在这一组数据中所有的01串长度均为n,然后给你一个含有m个元素的multiset,之后有q次询问。每次询问会给你一个01串t和一个给定常数k,让你输出串t和multiset里面多少个元素的“Wu”值不超过k。对于“Wu”值的定义:如果两个01串s和t在位置i上满足s[i]==t[i],那么加上w[i],处理完s和t的所有n位之后的结果即为这两个01串的“Wu”值。样例...原创 2019-05-08 12:35:03 · 202 阅读 · 0 评论 -
CodeForces - 992D Nastya and a Game
记录一下r[i],右边第一个不是1的数的位置,不会太多#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <string>#include <cmath>#include <vector&g...原创 2019-04-29 22:02:49 · 201 阅读 · 0 评论 -
CF 989D A Shade of Moonlight
考虑换一个思路,原题说的是两个人的速度同时加w,我们转换成月亮会进行移动。月亮以每个时刻从中间向两侧移动最多W个单位的速度移动。我们可以把时间放在纵坐标,把位置放在横坐标,画出如题解中的那样一张图。#include <iostream>#include <cstdio>#include <algorithm>#include <cst...转载 2019-04-28 21:18:10 · 348 阅读 · 0 评论 -
CodeForces - 986C AND Graph
x有边连出的一定是 (2^n-1) ^ x 的一个子集,直接连子集复杂度是爆炸的。。。但是我们可以一个1一个1的消去,最后变成补集的一个子集#include <iostream>#include <cstdio>#include <algorithm>#include <cmath>#include <vector>#in...转载 2019-04-27 22:31:09 · 200 阅读 · 0 评论 -
cf916b 思维
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <cmath>using namespace std;long long n;long long k;long long ct[200005];long ...原创 2019-03-13 11:45:25 · 268 阅读 · 0 评论 -
cf914c 暴力+组合(枚举1000)
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <string>#include <map>using namespace std;long long mod=1e9+7;char ch[...原创 2019-03-11 13:29:34 · 300 阅读 · 0 评论 -
【CodeForces】913 E. Logical Expression
【题目】E. Logical Expression【题意】令x=11110000(2),y=11001100(2),z=10101010(2),n次询问,每次要求用[与][或][非][括号]构成含至多各1个xyz的表达式使得结果等于给定的数字(0~255),要求表达式最短(一样短时字典序最小)。n<=10000【算法】数学+最短路?【题解】实际上给的数字只有256种情况,所以思路...转载 2019-03-08 20:48:56 · 154 阅读 · 0 评论 -
C. Qualification Rounds
C. Qualification RoundsSnark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quarter-finals. They have a bank of nproblems, and they want to select any non-...转载 2019-01-24 21:41:56 · 182 阅读 · 0 评论 -
CodeForces 865D Buy Low Sell High(思维)
Buy Low Sell Hightime limit per test:2 secondsmemory limit per test:256 megabytesinput:standard inputoutput:standard outputYou can perfectly predict the price of a certain stock for the next...转载 2019-01-24 10:54:41 · 293 阅读 · 0 评论 -
Codeforces Round #430 (Div. 2) C. Ilya And The Tree(dfs+因子+树)
C. Ilya And The Treetime limit per test 2 secondsmemory limit per test 256 megabytesinput standard inputoutput standard outputIlya is very fond of graphs, especially trees. During his last trip t...转载 2018-12-27 10:33:22 · 115 阅读 · 0 评论 -
Codeforces 822C Hacker, pack your bags (vector+upper_bound,或思维)
C. Hacker, pack your bags!time limit per test 2 secondsmemory limit per test 256 megabytesinput standard inputoutput standard outputIt's well known that the best way to distract from something is...原创 2018-12-14 19:28:53 · 2269 阅读 · 0 评论 -
CF806C:Prairie Partition(二分)
C. Prairie Partitiontime limit per test 2 secondsmemory limit per test 256 megabytesinput standard inputoutput standard outputIt can be shown that any positive integer x can be uniquely represent...原创 2018-12-01 16:46:15 · 174 阅读 · 0 评论 -
Codeforces 796D Police Stations (bfs+思维)
Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.Ruling a country is not an easy job. Thieves and terrorists are always ready to r...转载 2018-11-26 23:00:09 · 306 阅读 · 0 评论 -
D. Expected diameter of a tree(树形dp+期望)
【题目链接】 http://codeforces.com/contest/804/problem/D【题目大意】 给你一个森林,每次询问给出u,v, 从u所在连通块中随机选出一个点与v所在连通块中随机选出一个点相连, 问你此时相连出的树的直径期望是多少?(如果本身就在同一个连通块内,则输出-1)【题解】 我们利用树形dp记录每个点属于的连通块, 以及每个点到不...原创 2018-11-29 19:18:28 · 182 阅读 · 0 评论 -
HDU 5127 Dogs' Candies【CDQ分治+动态凸包】
HDU 5127 Dogs’ Candies【CDQ分治+动态凸包】题意:一个狗国家的狗国王有一个装糖的盒子,每颗糖有两个属性p,q,分别代表甜度和咸度,每只狗对于甜度和咸度的偏爱度不一样,所以每条狗有两个参数x, y,每颗糖对于特定的狗的美味度等于p*x+q*y。现在有50000个操作,分为三种:将新的糖(p,q)放入盒子中将盒子中存在的糖(p,q)吃掉给出一条狗的参数(转载 2017-09-20 23:06:40 · 297 阅读 · 0 评论 -
hdu5047(上海网赛1006)Sawtooth
题意:一个矩形画布。在上面画“M”,问画n个M,最多把画布分为几部分。 思路:找规律,研究画第二个M的时候,在第一个的基础上增加了多少区域。可以得出公式:16*n*(n-1)/2+2+n-1。然后因为结果爆long long,高精度搞超时,所以砍半来计算。#include #include #include #include #include转载 2017-09-12 22:37:51 · 177 阅读 · 0 评论 -
hdu 4850 Wow! Such String! 构造 欧拉回路
Wow! Such String!Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 934 Accepted Submission(s): 318Special JudgeProblem Description转载 2017-09-12 21:03:31 · 270 阅读 · 0 评论 -
codeforces 463E . Caisa and Tree
给一棵树, 两种操作, 一种是将点u的权值改为y, 另一种是查询根节点到点u的路径上, gcd(v, u)>1的深度最深的点v。 修改操作不超过50次。这个题, 暴力可以过, 但是在cf上找到了一个神奇的代码。 如果没有修改, 那么就将询问存起来。 如果有了修改, 就dfs一次, 将之前的询问都处理完, 然后在修改。 跑的很快、#include #include #includ转载 2017-08-21 22:57:22 · 202 阅读 · 0 评论 -
hdu4921 Map(状压统计)
hdu4921 Map(状压统计)题意:有10条长度不超过1000链,链上的节点有权值。我们从这些节点中选出一些节点来,若要选节点u,则u的前继都得被选进去。对于某一种选定的情况,我们能获得的权值为,选定的节点的权值和,以及一些附加值。附加值的求法为,对于每条链的同一深度的点,若选定的点的个数超过1,那么会得到的附加值为(si*xi/ci),其中si表示该层选中的点的权值和,xi为该层选中转载 2017-08-14 21:50:04 · 97 阅读 · 0 评论 -
CF 453A(Little Pony and Expected Maximum-若干次掷骰,最大那次期望-推公式)
http://blog.youkuaiyun.com/nike0good/article/details/38349347转载 2017-08-14 15:12:11 · 411 阅读 · 0 评论 -
poj2010 Moo University - Financial Aid
题意:一共有C名小牛,学校准备招收N名小牛入学,打算一共提供F奖学金,每名小牛有两个属性,成绩和希望得到的奖学金,问招收的N名小牛的中位数最大的情况是 ? 思路:先将C名小牛按照成绩排序,然后枚举每个小牛成绩作为中位数的情况是否满足 题意。 low[i],up[i]数组表示以i为中位数的小牛前面奖学金要求最少总和,和i后面要求奖学金数量最少总和。统计过程,借助优先队列,最大堆。 这题有转载 2017-08-14 11:14:35 · 140 阅读 · 0 评论 -
CF449C Jzzhu and Apples (筛素数 数论
题意:有N个苹果,编号为1~N。现要将苹果组成若干对,每对苹果最小公约数不为1。求最多能分成多少对,输出各对的组成。题解:先筛素数,然后搞。首先我们怕的是乱选了两个数组成了公约数不为1的一对,但是这导致了总对数减少(这两个数分别被别的数需要,它们组成一对了不是最优解)。为了防止这种情况,我们要想办法让总对数不会减少。我们发现2的倍数们非常碉炸,任意2个就能组成1对,所以我们转载 2017-08-13 16:05:20 · 298 阅读 · 0 评论