poj 2886 题目链接
题意:n 个人围成一圈,每个人身上有一个数,可正可负。从第 k 个人开始出圈,如果第 k 个人身上的数是 X,X>0,就左边第 x 个没有出圈的人出圈,否则右边第 -X 个人出圈。第 k 个人出圈得到的糖果数目为 f(k),f(x) 表示 x 的因子个数。现在问谁能拿到最多的糖果,并且拿到了多少糖果。
题目链接
题意:一个无穷数列,从1开始,初始第i个位置上为i,给出n个swap,每次交换两个位置的数。问交换 n 次以后得到的数列中,逆序对的个数。
思路:
官方题解:
At first find the position of each element which is used in swap (using map). Now let’s find the answer. It consists of the two parts. First part is the number of inversions formed by only whose elements which took part in the swaps. They can be counted by one of the standard ways: mergesort or Fenwick tree. The second part is the number of inversions formed by pairs of elements where one element has been swapped even once, and the other element stayed at his position. Let’s consider the following test:
题目链接
题意:
how many pairs of integers l and r are there, such that 1 ≤ l < r ≤ n and sequence b = _a_1_a_2… a__l__a__r__a__r + 1… a__n has no more than k inversions.
我花了两个小时才看懂题。。。。一直没懂b数列中a[l]和a[r]怎么就挨着了。。。
其实意思是。。。只保留a数列中1..l和r..n的。。。构成b数列。。。然后b数列的逆序对数小于等于k.问这样的l,r的对数。