problem1 link 二分答案,然后计算总时间.跟$T$比较确定要增大答案还是减小答案. problem2 link 可以看作是以‘*’所在位置为根的树.所以每个非根节点都有一个父节点. 那么每个非根结点$x$都可以表示其根结点$y$的函数,,类型为$x=p+qy$.比如说有三个节点$x,y,z$,$y$是$x$的父节点,$z$是$y$的父节点,那么有$x=1+y,y=1+\frac{1}{2}(x+z)=1+\frac{1}{2}(1+y+z)\rightarrow y=3+z$.也就是…
problem1 link 左括号和右括号较少的一种不会大于20.假设左括号少.设$f[i][mask][k]$表示处理了前$i$个字符,其中留下的字符以$k$开头($k=0$表示'(',$k=1$表示'['),且所有留下的字符状态为$mask$,($mask$的最高位为1,其他位为0表示另一种括号,否则表示跟最高位相同的符号). problem2 link 给定$n,m$,$n$个数字的排列有$n!$种,设其中某一种为$P_{i}$,设$P_{i}$中循环的个数$f(P_{i})=t_{i}$…
problem1 link 倒着想.每次添加一个右括号再添加一个左括号,直到还原.那么每次的右括号的选择范围为当前左括号后面的右括号减去后面已经使用的右括号. problem2 link 令$h(x)=\sum_{i=1}^{x}g(i)$,那么答案为$h(R)-h(L-1)$.对于$h(x)$: (1)如果$x\leq K$,那么$h(x)=0$ (2)否则对于$[K+1,x]$之间的所有偶数来说,对答案的贡献为$even+h(\frac{x}{2})-h(\frac{K}{2})$,其中$e…
Problem Statement You are given the ints perimeter and area. Your task is to find a triangle with the following properties: The coordinates of each vertex are integers between 0 and 3000, inclusive. The perimeter of the triangle must be exactly…
Problem Statement The Happy Letter game is played as follows: At the beginning, several players enter the field. Each player has a lowercase English letter on their back. The game is played in turns. In each turn, you select two players with dif…