[SPOJ419]Transposing is Fun 题意:给你一个$2^a\times2^b$的矩阵,将$1...n$中的数依次从左到右,从上往下填到矩阵里,再把矩阵转置,然后把所有数从左到右,从上往下拿出来得到一个新的排列$A$.你现在每次可以交换两个数,问你从$1...n$变成排列$A$最少要进行多少次操作. 询问次数$\le400000,a+b\le 10^6$ 题解:首先我们可以找到所有的循环节,如果一个循环节中有$x$个数,需要交换$x-1$次.所以我们只需要求出循环节的个数$k$…
GCD Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 3 Accepted Submission(s) : 2 Problem Description The greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written (a,b…
题目 Beads of N colors are connected together into a circular necklace of N beads (N<=1000000000). Your job is to calculate how many different kinds of the necklace can be produced. You should know that the necklace might not use up all the N colors, a…