题意:给定n和k,求第n个序列中第k个数是多少,序列是这样构造,原来只有1,然后再copy一遍放在到后面再在中间放上一个没有出现过的最小整数,就变成了 121,下次就成了1213121. 析:很明显是用递归来做,如果k在前半部分,那么就再递归,如果是在后半部分,那么就是先减一半再递归. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <st…
暴力肯定是无法做的 当时做的时候 当成一道递推来做的 用到分治的思想 想象一串长度为2n+1的列 那么前n个为前一串数 后n个是前一串数的reverse 第n+1个数 为第几串的编号 例如 第几串 中间的那个数 中间那个数的位置 长度 1 1 1 1 2 2   2  3 3 3 4  7 n n 2^(n-1) 2*len(n-1)+1 可以发现中间那个数总是代表了这一列个特征 那么把第n串的第1-2^(n-1)个数化为这个串都有效部分 因为后n个是前一串数的reverse 那么一个串的有效长…
B. Chloe and the sequence 题目链接 http://codeforces.com/contest/743/problem/B 题面 Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems to get to the olympiad like Vladik, but she was confused by the task proposed on the ol…
题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考虑:如果操作的次数最少,那么最终得到的不降的数列,必然是由原始数列中的数组成的,具体的证明可以使用反证法 知道了上面讲述的性质,这题就好搞了 先将原始数列(设为 A,共 n 个数)中所有的数去重并从小到达排序,保存在另一个数列中(设为 B,共 m 个数) 定义状态:f[i][j] 表示将原始数列中的…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems to get to the olympiad like Vladik, but she was confused by…
传送门 Description Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems to get to the olympiad like Vladik, but she was confused by the task proposed on the olympiad. Let's consider the following algorithm of generating a…
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 particular the favorite sequence of Picks. Fortunately, Picks remembers how to repair the sequence. Initi…
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the infinite sequence of integers: 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5.... The sequence is built in the following way: at first the number 1 is wr…
                                                            D. Chloe and pleasant prizes                                                            time limit per test 2 seconds                                                      memory limit per te…
Chloe and pleasant prizes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a pri…