[codeforces/edu4]总结(F)】的更多相关文章

链接:http://codeforces.com/contest/612/ A题: 枚举切多少个p,看剩下的能否整除q. B题: 从1到n模拟一下,累加移动的距离. C题: 先用括号匹配的思路看是否有解(所有左括号看做一样,所有右括号看做一样). 如果有解,就从左到右扫描,记录一个栈,遇到跟栈顶不匹配的右括号就替换一次. D题: 扫描线做一遍得到初步结果.然后合并一下初步结果得到最终结果. E题: 一个排列可以看成若干个环,一个排列的平方就是,奇数长度的环做了一次置换,偶数长度的环拆成了两个.所…
Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Input The first line contains a single integer nn (2≤n≤150000) — the number of kittens. Each of the following n−1lines contains integers xi and yi (1≤xi,…
Educational Codeforces Round 40 F. Runner's Problem 题意: 给一个$ 3 * m \(的矩阵,问从\)(2,1)$ 出发 走到 \((2,m)\) 的方案数 \(mod 1e9 + 7\), 走的规则和限制如下: From the cell (i, j) you may advance to: (i - 1, j + 1) - only if i > 1, (i, j + 1), or (i + 1, j + 1) - only if i <…
F. Doomsday Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/F Description Doomsday comes in t units of time. In anticipation of such a significant event n people prepared m vaults in which, as they think, it will…
F. FloodTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/F Description We all know that King Triton doesn't like us and therefore shipwrecks, hurricanes and tsunami do happen. But being bored with the same routine…
F. Ilya Muromets Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/problem/F Description I Ilya Muromets is a legendary bogatyr. Right now he is struggling against Zmej Gorynych, a dragon with n heads numbered from 1 to nf…
https://codeforces.com/contest/1132/problem/F 思维 + 区间dp 题意 给一个长度为n的字符串(<=500),每次选择消去字符,连续相同的字符可以同时消去,问最少需要消去多少次 题解 定义dp[l][r]为区间[l,r]剩下一个字符所需要的最小次数 dp[l][r]=min(dp[l][i]+dp[i+1][r]+x) x为消去剩下两个字符所需要的次数,假如两个字符相同需要x=-1 代码 #include<bits/stdc++.h> #de…
https://codeforces.com/contest/1051/problem/F 题意 给一个带权联通无向图,n个点,m条边,q个询问,询问两点之间的最短路 其中 m-n<=20,1<=n,m<=1e5 思路 因为图一定联通,所以n-1<=m<=n+20 因为是求任意两点的最短路,所以直接暴力跑最短路是不行的,考虑选择性的跑最短路 因为是求两点之间的距离,所以可以往lca方面想 先跑一棵生成树出来,然后处理出每个点的lca,这样就可以求出任意两点的距离 然后就可以记…
F. Ilya Muromets Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/problem/F Description I Ilya Muromets is a legendary bogatyr. Right now he is struggling against Zmej Gorynych, a dragon with n heads numbered from 1 to nf…
F. Four Divisors 题目连接: http://www.codeforces.com/contest/665/problem/F Description If an integer a is divisible by another integer b, then b is called the divisor of a. For example: 12 has positive 6 divisors. They are 1, 2, 3, 4, 6 and 12. Let's def…