随笔分类 - CodeForces
摘要:The graph is called tree if it is connected and has no cycles. Suppose the tree is rooted at some vertex. Then tree is called to be perfect k k -ary t
阅读全文
摘要:One of Arkady's friends works at a huge radio telescope. A few decades ago the telescope has sent a signal s s towards a faraway galaxy. Recently they
阅读全文
摘要:题意:N个人排成一行,分成K组,要求每组的不和谐值之和最小。 思路:开始以为是斜率优化DP,但是每个区间的值其实已经知道了,即是没有和下标有关的未知数了,所以没必要用斜率。 四边形优化。 dp[i][j]表示前j个人分为i组的最小代价。 622ms 利用DP决策单调性解决:684ms。二者时间差不多
阅读全文
摘要:题意:长度为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], [
阅读全文
摘要:A thief made his way to a shop. As usual he has his lucky knapsack with him. The knapsack can contain k objects. There are n kinds of products in the
阅读全文
摘要:As you know, the game of "Nim" is played with n piles of stones, where the i-th pile initially contains ai stones. Two players alternate the turns. Du
阅读全文
摘要:You are given a string ss. You should answer nn queries. The ii-th query consists of integer kiki and string mimi. The answer for this query is the mi
阅读全文
摘要:Yash is finally tired of computing the length of the longest Fibonacci-ish sequence. He now plays around with more complex things such as Fibonacci-is
阅读全文
摘要:At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in parti
阅读全文
摘要:There are well-known formulas: , , . Also mathematicians found similar formulas for higher degrees. Find the value of the sum modulo 109 + 7 (so you s
阅读全文
摘要:Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to
阅读全文
摘要:You are given n points on Cartesian plane. Every point is a lattice point (i. e. both of its coordinates are integers), and all points are distinct. Y
阅读全文
摘要:Little Petya likes to draw. He drew N red and M blue points on the plane in such a way that no three points lie on the same line. Now he wonders what
阅读全文
摘要:题意:给定N个点,用矩形将所有点覆盖,要求矩形宽度最小。 思路:裸体,旋转卡壳去rotate即可。 最远距离是点到点;宽度是点到边。
阅读全文
摘要:You are given n points with integer coordinates on the plane. Points are given in a way such that there is no triangle, formed by any three of these n
阅读全文
摘要:Count the number of distinct sequences a1, a2, ..., an (1 ≤ ai) consisting of positive integers such that gcd(a1, a2, ..., an) = x and . As this numbe
阅读全文
摘要:Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. However, one day, the No. 68 Cinema runs out of changes
阅读全文
摘要:Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred makin
阅读全文
摘要:Vasya has decided to build a zip-line on trees of a nearby forest. He wants the line to be as long as possible but he doesn't remember exactly the hei
阅读全文
摘要:Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by sw
阅读全文

浙公网安备 33010602011771号