Long Jumps CodeForces - 479D】的更多相关文章

E - Long Jumps CodeForces - 479D Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found anot…
479D - Long Jumps, 480B - Long Jumps It , or . If we can already measure both x and y, output . Then try to measure both x and y by adding one more mark. If it was not successful, print two marks: one at x, other at y. So, how to check ? Consider all…
[链接] 我是链接,点我呀:) [题意] 如果存在a[j]-a[i]=d 那么认为可以量出来长度d 现在给你量尺上的n个点. 问你最少要加多少个点,才能够量出来长度x和长度y [题解] 设dic1和dic2分别为 能量出长度x和长度y需要添加的点(所有能利用某个a[i]量出来长度为x或y的点) (输入a[i]的话,就把a[i]-x和a[i]+x加入dic1,把a[i]-y和a[i]+y加入dic2 (一开始我只加了a[i]-x......傻逼了) 如果一开始就能量出来x和y(不用这两个集合里面的…
题意: 给你n个数hi,你刚开始在第1个数的位置,你需要跳到第n个数的位置. 1.对于i.j(i<j) 如果满足 max(hi+1,-,hj−1)<min(hi,hj) max(hi,hj)<min(hi+1,-,hj−1) 那么就可以从i直接一步跳到j位置 2.如果j=i+1,那么也可以直接跳过去 问你从第一个位置跳到第n个位置,最少需要跳多少次 题解: 我们设dp[i]表示:从第一个位置跳到第i个位置最小需要跳多少次 我们最重要的就是找在[1,i-1]这个区间内的k,哪个位置可以跳到…
B. Long Jumps Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/480/problem/B Description Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorit…
题目链接: B. Long Jumps time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has l…
我们要统计的答案是sigma([L/K]),L为路径的长度,中括号表示上取整. [L/K]化简一下就是(L+f(L,K))/K,f(L,K)表示长度为L的路径要想达到K的整数倍,还要加上多少. 于是,我们现在只需要统计sigma((L+f(L,K))),最后除以K即可. 统计sigma(L)时,我们考虑计算每条边出现在了几条路径中,设u为edgei的子节点,那么这条边对答案的贡献就是siz(u)*(n-siz(u)),siz(u)为u的子树大小. 统计sigma(f(L,K))时,我们需要dp出…
[题目链接]:http://codeforces.com/contest/791/problem/D [题意] 你可以从树上的节点一次最多走k条边. (称为跳一次); 树为无权树; 然后问你任意两点之间的条的次数的和为多少; [题解] 如果k=1的话; 问题就是求任意两点之间的距离的和了; 这个可以在O(N)的复杂度下搞出来; 即 枚举每一条边; 看这条边左边的点的数目和右边的点的数目分别为多少->num1和num2 num1*num2就是经过这条边的路径个数; 累加所有的边的这个值就是任意两点…
Codeforces 题面传送门 & 洛谷题面传送门 nb tea!!!111 首先很显然的一件事是对于三个数 \(a,b,c\),其最大值与最小值的差就是三个数之间两两绝对值的较大值,即 \(\max(|a-b|,|b-c|,|c-a|)\),因此我们不妨从差分序列的角度解决这个问题.对于原序列 \(h\),我们假设其差分序列 \(d_i=h_{i+1}-h_i\),那么 \(\max(h_i,h_{i+1},h_{i+2})-\min(h_i,h_{i+1},h_{i+2})=\max(|h…
题意: 给出一棵树,一个人可以在树上跳,每次最多跳\(k(1 \leq k \leq 5)\)个点 定义\(f(s,t)\)为从顶点\(s\)跳到顶点\(t\)最少需要跳多少次 求\(\sum\limits_{s<t}f(s,t)\) 分析: 注意到\(k\)很小,为了方便转移,定义: \(sz(u,i)\)为\(u\)的子树中与\(u\)的距离模\(k\)等于\(i\)的孩子节点的个数 \(d(u,i)\)为从\(u\)跳到\(sz(u,i)\)对应的节点的跳数之和 转移: \(sz(u,(i…